Using PHP to implement file migration renaming, _php tutorial

Source: Internet
Author: User
Tags php language

Using PHP to implement file migration renaming,


First of all, this is a sad story.

Summer vacation, the school arranged for us to a software outsourcing company internship, think not to interview is quite convenient, can take this opportunity to learn from Daniel, although there is no salary (said the school also paid 600 pieces of insurance), but think still pretty look forward to, but really to the company on the ~ The technical staff are not good! Positions are arranged, what human resources, management, and financial management, and so on, do training, but not a write code Ah!

I was divided into the management department, the daily contact is a variety of contract approval, contract scanning, contract seal, contract ... In short, around the contract round, chores far more than study. It's a bit overwhelming for me to think that if people who are not in our company have to deal with such repetitive and tedious work.

No more chatter, I have a problem. The company contract text is scanned to the computer before it is archived and then uploaded to the corporate system. All the scanned contracts exist in a folder, originally scanned in order to facilitate the unified name

"cd+ year + month + contract number. pdf"; For example, the 10th contract of July 15 was named "Cd1507010.pdf". There are about 300 contracts per month. In order to upload to the system, there are two methods, one is a copy to the system, one is to rename the local package sent to the system. Manual operation, either of which is time-consuming at more than one hours. The repetition of such a boring job is simply a rush to collapse. For the first method, I did not do much more, because I did not understand the system, and I focused on the second approach. The local rename rule is to place the original PDF file under the folder "file name +c" and rename it to Htwb.pdf.

In the principle of repeating work as far as possible to the computer, I consider using the PHP language I have learned to solve the problem. (It is not known whether other languages are more efficient, but this is significantly more efficient than purely manual).

The company's computer is configured as a win7 system, although a software company, but non-research and development Department of the computer level and the general company. Taking into account the operator's knowledge of the computer and the ease of implementation, I did not install the Apache server or even start the Windows-brought IIS, directly using the command line .

The script named htzy.php is as follows:

 
  $path=dirname(__file__); $handle=opendir($path);  while (! ($item=readdir($handle)) = =false)    {if ( $item! = '. ' &&$item! = ' ... ' &&$item! = ' htzy.php ')        {$arr=explode$item );         $dirname=$arr[0]. ' C ';         mkdir ($path. ' /'. $dirname );         Rename ($path. ' /'. $item,$path. ' /'. $dirname. ' /htwb.pdf ' );}    } unlink ('./htzy.php '?>

Place this file under the folder you want to work with, open a command-line window in the folder, enter

      Php-f htzy.php

Just wait a few seconds.

Simply use the mkdir () rename () function to complete the file transfer and finally use unlink to delete the script, so you need to save it to reuse this script ~

At this point, the file migration rename is complete.

Knowledge is power~

http://www.bkjia.com/PHPjc/1034807.html www.bkjia.com true http://www.bkjia.com/PHPjc/1034807.html techarticle using PHP to implement file migration renaming, first of all, that this is a sad story. Summer vacation, the school arranged for us to a software outsourcing company internship, think not to interview is also barbarian square ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.