Technical support and scripting issues
Moderators: Dorian (MJT support), JRL
-
Identis
- Junior Coder
- Posts: 26
- Joined: Fri Mar 27, 2015 11:26 am
Post
by Identis » Thu Nov 24, 2016 5:56 am
Hello,
I want to delete older than 5days files, but I don't know how to write "If" for it. Please help me.
Thank You.
Code: Select all
GetFileList>C:\temp\cs\*.csv,files
Separate>files,;,file_names
Let>k=0
FileDate>C;\temp\cs\*.csv,FailoData
GetDate>date
Repeat>k
Let>k=k+1
if>
DeleteFile>k
Until>k,file_names_count
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Thu Nov 24, 2016 9:16 am
Use the IfFileChanged command:
Code: Select all
GetFileList>C:\temp\cs\*.csv,files
Separate>files,;,file_names
If>file_names_count>0
Let>k=0
Repeat>k
Let>k=k+1
Let>this_file=file_names_%k%
IfFileChanged>this_file,>5
DeleteFile>this_file
Endif
Until>k,file_names_count
Endif
-
Identis
- Junior Coder
- Posts: 26
- Joined: Fri Mar 27, 2015 11:26 am
Post
by Identis » Thu Nov 24, 2016 9:56 am
Marcus Tettmar wrote:Use the IfFileChanged command:
Thank You!! Works very well
-
Identis
- Junior Coder
- Posts: 26
- Joined: Fri Mar 27, 2015 11:26 am
Post
by Identis » Fri Nov 25, 2016 11:14 am
Marcus Tettmar wrote:Use the IfFileChanged command:
Code: Select all
GetFileList>C:\temp\cs\*.csv,files
Separate>files,;,file_names
If>file_names_count>0
Let>k=0
Repeat>k
Let>k=k+1
Let>this_file=file_names_%k%
IfFileChanged>this_file,>5
DeleteFile>this_file
Endif
Until>k,file_names_count
Endif
Need more help.
I have 1 folder there are many subfolders and files in it, how can i go through all subfolders and check for older files and delete them?
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Fri Nov 25, 2016 12:34 pm
Make a loop which loops through all subfolders. Inside that loop put your existing code. So you have a loop within a loop.