Citect, Delete Files Older then X.

kire

Member
Join Date
Apr 2014
Location
UK
Posts
55
Hi

I try to write a cicode function who shall delete all files files in a foler who is older then example 4 days.

Filenames format is like these:
10102015.701.csv
11102015.702.csv
12102015.701.csv
13102015.701.csv

I have found function Filedelete(),
but have not figure out how to use it in these matter...

Anyone give me a example?

Your feedback / input is feedback much appreciated.
[FONT=&quot][/FONT]
 
Hi

I try to write a cicode function who shall delete all files files in a foler who is older then example 4 days.

Filenames format is like these:
10102015.701.csv
11102015.702.csv
12102015.701.csv
13102015.701.csv

I have found function Filedelete(),
but have not figure out how to use it in these matter...

Anyone give me a example?

Your feedback / input is feedback much appreciated.
[FONT=&quot][/FONT]

Well the filedelete function is pretty straight forward and is all detailed in the help file, FileDelete("C:\Data\Report.Txt");

The trickier bit is deciding what's older than 4 days but if the filename contains the date it should be simple enough, you just need to read the filename, decide what's older than 4 days and call the filedelete function.
 
Well the filedelete function is pretty straight forward and is all detailed in the help file, FileDelete("C:\Data\Report.Txt");

The trickier bit is deciding what's older than 4 days but if the filename contains the date it should be simple enough, you just need to read the filename, decide what's older than 4 days and call the filedelete function.

Agree with you, but its is the tricki part, I need help for :)
Can I load current date and then take subtract 3 and delete rest?
Can you give me a example how can do something like that?
And what about a month have different numbers of days?
 
Agree with you, but its is the tricki part, I need help for :)
Can I load current date and then take subtract 3 and delete rest?
Can you give me a example how can do something like that?
And what about a month have different numbers of days?

Never done it myself but I would use FileSplitPath to give the the filename, then extract the date part, use Date function to get the current date then go from there.
 
I solve it my looking at age on the file itself and not the file name.

Thank you for respons.
 

Similar Topics

Hello, I have a running project on Citect v5.42 and simatic net v6.4 I have created a new spare PC and loaded all software like Citect, station...
Replies
0
Views
68
Hello everyone, In a factory where we installed Citect 7.20 the computer began to show the first signs of end of life. They never considered...
Replies
0
Views
73
I have a running backup of Citect and plc and I want to make a spare PC station so I have installed the win XP and somatic net v6.0 and import the...
Replies
3
Views
121
I am trying to display a variable within a cicode function onto a graphics page. This function queries a SQL database. I can get the value onto a...
Replies
3
Views
287
Looking for some help with the connection issue between Citect 2018 and Top Server v6 for Opto22. I’m setting all this up to communicate with some...
Replies
0
Views
119
Back
Top Bottom