且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

批处理文件创建备份和时间戳重命名

更新时间:2022-12-16 08:05:49

试试这个:

 仁文件1-1文件1  - %日期:/ =  - %%的时间:: =  - %

I have the following network path to copy the file to an archive folder. It copies File 1 from Folder to Archive but I would like to add these 2 adjustments that won't work.

  1. Rename File 1-1 to File 1 - date + time
  2. Running it now displays a cmd box with the copy code, is it possible to run it in the background or have a loading screen to show the progress?

For my code I followed this example to change the name to a date.

copy "F:\Folder\File 1.xlsx" "F:\Folder\Archive\File 1-1.xlsx"
/f "tokens=1-5 delim s=/ " %%d in ("%date%") do rename "F:\Folder example 2.xlsx" "F:\Folder\File example %%e-%%f-%%g.xlsx"

try this:

ren "File 1-1" "File 1 - %date:/=-% %time::=-%"