Sign in to follow this  
Followers 0
Guest nate020605

Delteing Files by date last accessed

12 posts in this topic

I'm curious if there is a way to search a network directory such as a shardedrive and delete old files by date last accessed. i havnt found anything in AutoIt that would check the date last accessed, Simply put I need Advice on how to.

1. Write a script that will Search a Drive

2. Find out the date last accessed of all files

3. delete them if they exceed the specified length of time.

Thanks for all the help in advance

Share this post


Link to post
Share on other sites



1. FileFindFirstFile and FileFindNextFile.

2. FileGetTime (option 2).

3. If file time > exceeded time then FileDelete.

You'll also want to check out Loop Statements.

Share this post


Link to post
Share on other sites

Please excuse my newbiness but is the above link the udf.

Yes

See the part that starts with the line:

Func _Remove_Files($T_Dir,$T_Incl_SubDir,$T_Days)


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thanks herewasplato for the reply.

I still don't understand the usage of this script. Can I call the the udf and pass arguments to it like path and age, if so what is the syntax for that, or do I need to edit the script and hardcode the age and path of files I want to delete?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks herewasplato for the reply.

I still don't understand the usage of this script. Can I call the the udf and pass arguments to it like path and age, if so what is the syntax for that, or do I need to edit the script and hardcode the age and path of files I want to delete?

Please do not run this script if you dont understand what it does..

It was intended to get you a head start.

Deleting files is never a trivial thing to just grab somebodies script and "Try" it ...

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Please do not run this script if you dont understand what it does..

It was intended to get you a head start.

Deleting files in never a trivial thing to just grab somebodies script and "Try" it ...

I appreciate your concern. however it doesn't help me a whole lot. I was doing some research on udfs, and from what I understood they are code snippets that you can use in scripts by just including the .au3. So if I saved your script as delfiles.au3 and included it in another script, I could just call the function remove files and pass it parameters. Is that correct?

Share this post


Link to post
Share on other sites

I appreciate your concern. however it doesn't help me a whole lot. I was doing some research on udfs, and from what I understood they are code snippets that you can use in scripts by just including the .au3. So if I saved your script as delfiles.au3 and included it in another script, I could just call the function remove files and pass it parameters. Is that correct?

That is correct ... all I am saying is make sure you comment the filedelete() portion while testing ...

The UDF makes a logfile where you can check what it would have done ..

:)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks herewasplato for the reply.

I still don't understand the usage of this script...

Neither do I :-)

I would have to study each line - but I have no need for this UDF at this time - so... that task will fall to you.

..and like JdeB said, you can "include" the file using the include file.

(or just copy/paste it to the bottom of your main script)

...enjoy...


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thanks guys appreciate your help. The script works beautifully. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0