Current time obtained by batch processing

Source: Internet
Author: User
Rem code by t0nsha

Rem indicates a batch process for extracting the output results of date and time.

Rem ":" (colon) and "~" The Tilde is indispensable!

Rem "~" The following number: a positive number indicates that the first few digits of the output result are discarded. A negative number indicates that the last digit of the output result is obtained.

Number after REM ",": positive number indicates the first digit of the output result. negative number indicates that the last digit of the output result is discarded.

Echo % date %

Echo % Date :~ 4%

: Indicates that the first 0 digits are discarded and the first 10 digits of the output result are discarded)

Echo % Date :~ 0, 10%

Echo % Date :~ 4,-5%

Pause

Echo % time %

Echo % time :~ -3%

Echo % time :~ 2.-3%

Pause

Echo % Date :~ 4% % time :~ 0,-3%.

Pause BTW uses batch processing to generate date (time) files and folders to help others to automatically back up SQL Server

Failed to use network ing drive as backup file storage path

The ephemeral disk space is insufficient.

So I decided to back up only the latest 2-day data on the local machine.

Write another batch for system scheduling.

How to copy the backup data to the network drive every week and archive the files generated by batch processing from the Internet

The following is a good batch processing file:

@ Echo off

Set afile = Bak-% Date :~ 4,4% % Date :~ 9,2% % Date :~ 12,2%

Set bfile = Bak-% time :~ 0, 2% % time :~ 3,2% % time :~ 6, 2%

Set cfile = Bak-% date %

Echo afile = % afile %

Echo bfile = % bfile %

Echo cfile = % cfile % output:

Afile = bak-20061219

Bfile = bak-113202

Cfile = Bak-Tuesday, so back up bat.

@ Echo off

ECHO is backing up data to the network drive...

Set folder = % date %

MD "Y: \ % folder %"

Copy D: \ databak \ *. Bak "Y: \ % folder %"

Echo backup is complete. Bytes ------------------------------------------------------------------------------------------------------

@ Echo off

Set afile = Bak-% Date :~ 4,4% % Date :~ 9,2% % Date :~ 12,2%

Set bfile = Bak-% time :~ 0, 2% % time :~ 3,2% % time :~ 6, 2%

Echo afile000000000000afile0000.rar

Echo bfile00000000bfile0000.rar
Result of running this batch:

Afile1_bak-20060109.rar ------- year, month, and day -- 8 bits

Bfile1_bak-14020..rar ---------- hour, minute, and second -- 6 digits; Other: if the number of hours is only one digit, leading to an error due to space in the middle, use the following method to add 0

Set HH = % time :~ 0, 2%

If/I % HH % LSS 10 (set hh= 0% time :~ 1, 1%)
Http://blog.chinaunix.net/uid-11848011-id-96434.html

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.