This may be simple to those of you that script regularly but i don't and am not very technical but what i need to do is this;
Find oldest file in a folder - all files will have year/month/date/hour/min/sec after base file name
Copy that file to a new folder removing the year/month/date/hour/min/sec after base file name
Delete file in original location
I have searched posts but cant find anything similar to copy, please help
Oldest file copy and delete
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7380
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Oldest file copy and delete
Hi,
You can use the GetOldestFile function to return the oldest file in a folder.
That works off the file date. But if - as I think you are saying - it is the filename that determines "oldest" and not necessarily the modified date, then I would use GetFileList and sort the array then take first or last. If you have a sensible naming convention like YYYYMMDD then sorting it would be enough. If not you'd need a loop, parsing each filename in turn, to find the one which has the oldest date in it.
You can use the GetOldestFile function to return the oldest file in a folder.
That works off the file date. But if - as I think you are saying - it is the filename that determines "oldest" and not necessarily the modified date, then I would use GetFileList and sort the array then take first or last. If you have a sensible naming convention like YYYYMMDD then sorting it would be enough. If not you'd need a loop, parsing each filename in turn, to find the one which has the oldest date in it.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?