Use the current date and time as the file name in the Windows shell script

Source: Internet
Author: User
Tags windows shell script

In Windows shell scripts, if you want to use the current date and timeCompositionFile name. You can use the following method:

  1. First obtain the string of the current date and time;
  2. Separate the desired characters;
  3. Finally, splice the file into a complete file name.

ExampleCodeAs follows:

Echo% Date %Echo% Time %SetDatetimef= % Date :~ -4% _ % Date :~ 3, 2% _ % Date :~ 0, 2%__ % time :~ 0, 2% _ % time :~ 3, 2% _ % time :~ 6, 2%Echo% Datetimef %

In an English Windows environment, the output may be as follows:

13/04/2010:00:43. 312010_04_131_11_00_43

In a Chinese environment, you may need to simply process strings based on the system date and time format.

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.