1.

Solve : help with deleteing files based on file name?

Answer»

hey all,

I have loads of files that need sorting.

In a nut shell an avi file is created each time someone walks past a camera at work. We need to keep a solid month but delete everything older.

I'm going to be adding this as a scheduled task and I'm after help as to how to go about it.

the files are NAMED like this; yyyymmddhhmmss (year month day hour minute second) 20090623163154.avi

What the best way to go about this??

Should i be trying to compare file names against the system date (month only) and then deleting everything else or is there a better way??

Any thoughts would be greatly appreciated This can be done a number of ways ( Date/time stamp checked - or - have the routine store the avi's into FOLDERS for each month and have a process that performs a clean up that is automated to delete the folder older than 2 MONTHS so that say on July 1, you dont lose June's data, but May will disappear).

The lesser complicated being a monthly routine that on the first day of the next month it Moves all avi's from the last Month Folder to 2ndMonth folder, then Move all local avi's to the last month folder, then on the last day of the month delete all avi's from the 2ndMonth folder so the next day on the 1st, the avi files from last month them move into 2nd month and the process repeats over and over again in a shuffle and deletion process.

Hi thanks for the reply.

I hadn't thought about using folders to organise it and then cleaing up the older folders. - Good idea


How can i LIST all the month numbers (cut form file name or from date modified) that are currently in the folder and then assign to a varaible??

Chees again

So are you saying you want to get all the months that each of the files were made in(or there file name) and set to variable? Quote from: blastman on June 23, 2009, 09:33:10 AM

Any thoughts would be greatly appreciated

download GNU findutils(SEE my sig),and use the find command , problem solved.
Code: [Select]c:\test> find_gnu.exe  c:\path -type -f -name "*.avi" -mtime +30 -delete
the one liner above delete avi files more than 30 days old. cheers for all the replies guys.

I'm going to cheat as I found a vbs script I'd written a few years ago and managed to change a few details to get what i wanted.

Thanks for all the comments.


Discussion

No Comment Found