forfiles /p "C:FILEPATH\TO\BE\DELETED\User_1" /s /m *.* /c "cmd /c Del @path" /d -08
forfiles /p "C:FILEPATH\TO\BE\DELETED\User_2" /s /m *.* /c "cmd /c Del @path" /d -08
forfiles /p "C:FILEPATH\TO\BE\DELETED\User_3" /s /m *.* /c "cmd /c Del @path" /d -08
forfiles /p "C:FILEPATH\TO\BE\DELETED\User_4" /s /m *.* /c "cmd /c Del @path" /d -08
forfiles /p "C:FILEPATH\TO\BE\DELETED\User_5" /s /m *.* /c "cmd /c Del @path" /d -08
@echo off
@echo This purge was successfully completed on the date listed in the file name.
>purgelog_%date:~-10,2%%date:~-7,2%%date:~-4,4%_.txt
( command1
command2
...
commandN
)
Asked
Active
Viewed 640 times
-1
-
Please, can you expand the description of your problema dn your attempt of solution? Thank you – alepuzio Sep 08 '17 at 22:53
-
1How to make this bat file output the results to a .txt file? - by using redirection operators. – Sep 09 '17 at 02:42
-
@Jay, I have placed all of your code into a formatted code block, it is however not clear what your original code looked like. Can you please check the code and confirm whether what you see is exactly as you have it in your script. – Compo Sep 09 '17 at 11:50
1 Answers
0
If this is stored in my.bat, simply use redirection.
my.bat >my.txt
If you also want stderr to go into the same file, use:
my.bat >my.bat 2>&1
Note that this will not put the purgelog*
information go into my.txt because its target file is explicitly specified.

lit
- 14,456
- 10
- 65
- 119