Create a file name with a timestamp under Windows

Source: Internet
Author: User

English environment:

echo Archive_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.zip

Chinese:

    1. echo generates the file name based on the current date time, ...
    2. Set yyyymmdd=%date:~0,4%%date:~5,2%%date:~8,2%
    3. Set hhmiss=%time:~0,2%%time:~3,2%%time:~6,2%
    4. Set "Filename=website3copy%yyyymmdd%_%hhmiss%.zip"
    5. Echo%filename%

How to remove spaces:

  1. C:\>set h=%time:~0,2%
  2. C:\>set h=%h: =0%
  3. < Span class= "Hljs-symbol" > c:\> echo%date:~0,4 %%date:~5,2%%date:~8,2%%h%%time:~3,< Span class= "Hljs-number" >2%%time:~6,2%
  4. 20150324090254

Reference Links: http://blog.csdn.net/chinadm123/article/details/44588891

http://blog.csdn.net/xuexiaodong009/article/details/53462592

Https://stackoverflow.com/questions/7727114/batch-command-date-and-time-in-file-name

My Backup Mantis script:

CD C:\Program files\mysql\mysql Server 5.6\bin

Set h=%time:~0,2%
Set H=%h: =0%
Set "Filename=mantis_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.sql"
Echo%filename%

MYSQLDUMP-UROOT-P3EDC$RFV bugtracker > \\172.16.10.240\Infa_Shared\Mantis\%filename%

Create a file name with a timestamp under Windows

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.