Need help with the ForFiles command


Recommended Posts

I have the command in a bat file like this:

ForFiles /p "H:\CCTV\video" /s /d -30 /c "cmd /c del /q @file"

To clear out any file greater than 30 days old, this seems to work somewhat, but there are 4 sub-folders with in the CCTV folder, and it appears that it seems to be clearing 3 or 4 but it doesn't seem to be doing anything in the 4th, the command is still running, but does not appear to be doing anything else. Is that syntax correct for clearing all folders?

Link to comment
Share on other sites

On 01/08/2022 at 18:07, Biscuits Brown said:

Think you need a /s in there after (I think) the /p

OK, I'll add that in and see what happens!

 

It is still ignoring the last folder. The folder structure is Back Door, Back Door 2, Driveway, Front Door

The first 3 Back doors and driveway I can see that the most recent file is from July, however in Front Door I have files from 2-19-22 still. So I am confused as to why it is ignoring that folder.

Even going to the folder directly and modifying the command to:

ForFiles /p /s "H:\CCTV\video\Front Door" /s /d -30 /c "cmd /c del /q @file"

does not do anything at all.

Edited by jnelsoninjax
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.