I would like the script to look for folders that were created older than 2 weeks then delete them, but I dont see any command that would do that
thank you
how to get file older than 1 or 2 weeks
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Use GetFileList to return a list of files. Separate to split to an array. Loop through the array of files and use FileChangedSince, or FileDate to see if the file is 2 or more weeks old.
Similar:
http://www.mjtnet.com/forum/viewtopic.php?p=5835
Similar:
http://www.mjtnet.com/forum/viewtopic.php?p=5835
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?
Here's a pure Macro Scheduler sample of how this might be done. As Marcus said, you could use Filelist> and separate> to get the file names. In the sample I've simply set the name of a variable to the name of a file.
Read the commentary about date format in the post Marcus has linked. This script works on my computer but might fail for some other computer depending on how the computer is configured.
Read the commentary about date format in the post Marcus has linked. This script works on my computer but might fail for some other computer depending on how the computer is configured.
What is FileChangedSince?use FileChangedSince, or FileDate
Code: Select all
Let>filename=C:\test.txt
GetDate>today
FileDate>filename,file_date
Midstr>file_date,1,4,yyyy
Midstr>file_date,5,2,mm
Midstr>file_date,7,2,dd
Let>file_date=%mm%/%dd%/%yyyy%
Let>kk=0
Repeat>kk
Add>kk,1
Sub>today,1
If>%today%=%file_date%,DoNotDel,Continue
Label>DoNotDel
Let>kk=14
Let>DeleteFlag=NO
Label>Continue
Until>kk=14
If>deleteflag=NO,SkipDelete
DeleteFile>filename
Label>SkipDelete