I'm trying to find all files older than 30 days in several directories using this command:
[Directory] && forfiles /d -30 /c "cmd /c echo @path"
The output is a .txt file.
The text file contains the path to the directory: C:\Directory1 C:\Directory2 C:\Directory3 etc
I'm trying to loop through several directories using a text file but I need to provide 2 commands: cd (to change to the directory whose files I need info on) and the actual command to get the information)
If I create a batch file entering the directory names manually I have something like this:
cd "C:Directory1" && forfiles /d -30 /c "cmd /c echo @path"
cd "C:Directory2" && forfiles /d -30 /c "cmd /c echo @path"
cd "C:Directory3" && forfiles /d -30 /c "cmd /c echo @path"
How do I enter the "cd" command at the beggining of the loop, then the directory which is in the txt file and the rest of the command (forfiles /d -30 /c "cmd /c echo @path")
What I have so far is:
for /f "usebackq tokens=*" %%A in ("C:\list.txt") do forfiles /d -30 /c "cmd /c echo @path %%A
Thanks!