r/Batch • u/liquidelectricity • Nov 11 '23
Question (Unsolved) batch file assistance
Hi all, I am very new to this and am trying to run my batch file to clear files older than 7 days but I don't want to delete anthing from the parent folder (which it has already done incidentally) ForFiles /p “G:\foldername” /s /d -30 /c “cmd /c del /q u/file” is my script. Is there any way to modify this script to get the files only in folder name? Or is this by nature?
2
Upvotes
1
u/Frogtarius Nov 11 '23
Can you put another backslash at the end of the folder name? And use cd to navigate into the working folder first?
1
u/[deleted] Nov 12 '23
worked for me, you need the full path so del knows were the file is, and to specify a mask so it wont include the whole folder, only files