Link to home
Start Free TrialLog in
Avatar of ranski
ranski

asked on

Delete files older than 30 days by created date not modified...

Hi all,

I'm trying to put together a script to delete any files from a shared area that have been created more than 30 days ago. I have used the below scripts in a batch file from robocopy and from forfiles but neither seems to do what I want.

FORFILES /p c:\temp /s /m *.* /d -10 /c "cmd /c del /q @path"

and

"C:\WINDOWS\system32\ROBOCOPY.EXE" c:\test\ c:\test\old  /move /sec /e /XO /r:1 /w:1 /minage:30

The problem is that it deletes files older than 30 days when looking at the modified date not the created date. The idea is that the shared area is for transferring files from one server to another. Thus the created date is different to the Modified date.

Is there a way to delete files older than 30 days from the created date? See 'A' in attachment and not 'B' the modified date

thanks

screenshot1.JPG
ASKER CERTIFIED SOLUTION
Avatar of Speshalyst
Speshalyst
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The way the above code is written, you need to be in the directory you want to delete files from when you execute it.  You will probably want to change the getfolder(".") to getfolder("c:\temp").
Another question:  Do you really want to delete the files or do you want to move them?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial