Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting files

Status
Not open for further replies.

Myqns

Programmer
Jul 28, 2004
23
GB
I have 'n' number of files on a server. The files are ftp'd to the server every 15 minutes. The file names look like abc_200408101850.csv(It has year/month/date/hour/min/sec). I want to delete the files that doesn't have today's date. Again, I have to delete using a ssh beacuse they reside on the server. I am unable to think of a clean logic. Does the following sound good?

1. Read the dir.
2. Check for the today's date in the file name.
3. If yes, don't delete the dile.
4. If no, then delete the file.

Thanks

 
Your logic is sound but to simplify things, just check for files that are not today's date. Or, if you can run a cron job, just delete all the files in the directory at 12:01 am. This will delete all of "yesterday's" files.

There's always a better way. The fun is trying to find it!
 
I cannot run a cron job on that server. I have to execute the pl script thro' autosys on an NT box. I have to always store the previous day's file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top