Xcopy only copies the implementation code for the day file _dos/bat

Source: Internet
Author: User
Recently, due to the Mesis database automatic station data, it is necessary to copy the regional automatic station data files from the Cmacast broadcast directory L1 for storage. In the actual operation encountered a few problems, hereby make a memo to find later.

Problem 1:micdb specified source directory as long as there are files on the processing, the library into the program is very resource-intensive, with the PC processing to pay attention to efficiency, it is best to put the latest files at a time to reduce the duplication of processing.

Problem 2:cmacast broadcast directory L1 file too much, 3 days have more than 490,000 files, light open the directory will read n minutes, the National Bureau of Information Center technicians are eating feces. The original use of sceondcopy copy function is very powerful, you can only copy the latest files, but the number of files on this directory is too large, the last implementation. (Newzfile from SJK copy can be used secondcopy)

To solve the above 2 problems, the use of Xcopy first L1 directory of the province automatically copy the file, placed in the D:\AWS\ZFILE (scheduled task implementation), and then use Scondcopy to D:\AWS\ZFILE the latest files to D:\Program files\ Read in Micdb\tempdata\zfile for micdb into the library.

xcopy used the/d:mm-dd-yyyy parameter, that is, only the file after the specified date, the date of the day to generate, using the%date% to obtain the system date, if the general Chinese XP system, the date format is YYYY-MM-DD, So the date format of the United States was reconditioned in the form of an intercept string. For example:%date:~0,4% that the interception from the No. 0 bit to intercept the length of 4 characters to get yyyy (year), such as:%date:~5,5% said interception from the 5th bit to intercept the length of 5 characters to get MM-DD (month-day)

In order to facilitate users and their browsing cloud habitat special will be content, easy to learn

command to get system time in DOS

Copy Code code as follows:

Echo%date%


Output:



Intercept 4-digit year variables after reading system date (China date format year-month-day)
Set nian=%date:~0,4$
Test
Copy Code code as follows:

Echo%date:~0,4%


Output:



Intercept the 2-digit month variable after reading the system date
Set yue=%date:~5,2%

Test:

Copy Code code as follows:

Echo%date:~5,2%

Output:

Intercept 2-bit day variables after reading the system date

Set ri=%date:~8,2%

Test:

Copy Code code as follows:

Echo%date:~8,2%


Output:

Reshape the U.S. date variable format "month-day-year", only select files that copy the current date

Copy Code code as follows:

xcopy \\172.22.68.4\sjk\zp\*.* e:\test/d:%yue%-%ri%-%nian%

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.