Batchfile to create backup and rename with timestamp

后端 未结 5 846
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-31 20:35

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 t

5条回答
  •  抹茶落季
    2021-01-31 21:09

    Renames all .pdf files based on current system date. For example a file named Gross Profit.pdf is renamed to Gross Profit 2014-07-31.pdf. If you run it tomorrow, it will rename it to Gross Profit 2014-08-01.pdf.

    You could replace the ? with the report name Gross Profit, but it will only rename the one report. The ? renames everything in the Conduit folder. The reason there are so many ?, is that some .pdfs have long names. If you just put 12 ?s, then any name longer than 12 characters will be clipped off at the 13th character. Try it with 1 ?, then try it with many ?s. The ? length should be a little longer or as long as the longest report name.

    @ECHO OFF
    SET NETWORKSOURCE=\\flcorpfile\shared\"SHORE Reports"\2014\Conduit
    REN %NETWORKSOURCE%\*.pdf "????????????????????????????????????????????????? %date:~-4,4%-%date:~-10,2%-%date:~7,2%.pdf"
    

提交回复
热议问题