Forfiles Batch Script (Escaping @ character)

后端 未结 8 966
闹比i
闹比i 2020-12-15 05:35

I\'m working on a batch script that will let me delete files older then a set period using forfiles. For now, I\'m aiming at printing the files that will be deleted.

8条回答
  •  被撕碎了的回忆
    2020-12-15 06:21

    dir *.* > C:\path\dummy%date:~4,2%%date:~7,2%%date:~10,4%.DAT
    
    dir *.* > C:\path\dummy%date:~4,2%%date:~7,2%%date:~10,4%.csv
    
    forfiles -p C:\path\ -m *.DAT /d -50 /c "cmd /c del /Q @path"
    forfiles -p C:\path\ -m *.csv /d -50 /c "cmd /c del /Q @path"
    
    1. Replace the .dat and .csv files what u want to delete.

    2. -50 delete older then 50 days

    3. This is the windows batch file

提交回复
热议问题