Sign in to follow this  
Followers 0
mrrlg

Move files after certain date

12 posts in this topic

Script masters, I need to be pointed in the right direction. I have been asked to come up with a script that will be run on a daily basis that will open a file or files on a server and remove (move to another folder) any files older than a certain date. Obviously, the cut off date will have to increment by one, and the script will need to run as a scheduled task. Any ideas?

Share this post


Link to post
Share on other sites



Script masters, I need to be pointed in the right direction. I have been asked to come up with a script that will be run on a daily basis that will open a file or files on a server and remove (move to another folder) any files older than a certain date. Obviously, the cut off date will have to increment by one, and the script will need to run as a scheduled task. Any ideas?

Did you try the search... there was something on this I believe in the last 2 months (maybe 3).

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

just playing here

#include <Date.au3>

$t =  FileGetTime(@Windowsdir & "\Notepad.exe", 1)
$yyyymd = $t[0] & "/" & $t[1] & "/" & $t[2]
$iDateCalc = _DateDiff( 'd',$yyyymd,_NowCalc())

If $iDateCalc > "60" Then
    MsgBox( 4096, "", "File deleted over 60 days old: " & $iDateCalc )
EndIf

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Did you try the search... there was something on this I believe in the last 2 months (maybe 3).

i'd say 3-4, it was when i was playing with recursion because i remember offering one recursive approach...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Sorry it took so long to get back, I had searched scripts and scraps before posting my question, didn't find anything there. I will look in the general forum and see what I can find.

Share this post


Link to post
Share on other sites

Sorry it took so long to get back, I had searched scripts and scraps before posting my question, didn't find anything there. I will look in the general forum and see what I can find.

did you try my example???

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I need to open a specific folder and all sub folders and files within. I then need to move (not delete) any files within the sub folder older than 7 days.

I experimented with the first portion of your script but I could not generate a list of file times.

#include <Date.au3>

$t =  FileGetTime(@Windowsdir & "\Notepad.exe", 1)
$yyyymd = $t[0] & "/" & $t[1] & "/" & $t[2]
$iDateCalc = _DateDiff( 'd',$yyyymd,_NowCalc())

What am I missing?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I need to open a specific folder and all sub folders and files within. I then need to move (not delete) any files within the sub folder older than 7 days.

I experimented with the first portion of your script but I could not generate a list of file times.

#include <Date.au3>

$t =  FileGetTime(@Windowsdir & "\Notepad.exe", 1)
$yyyymd = $t[0] & "/" & $t[1] & "/" & $t[2]
$iDateCalc = _DateDiff( 'd',$yyyymd,_NowCalc())

What am I missing?

ok, i will look for the other thread because i KNOW that this exact thing was done fairly recently.

***edit***

blah. no time to really search right now. check this out for file searching

Edited by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

This portion of script provides the basis of what I am looking for. I can run it against a remote folder and it will generate a list of files based on the file extention I specify. The folder I will run it against in my production environment has three file extentions that I need sort and move to another folder based on their creation date. These extentions are none, .txt and .xls. I have been trying to insert the code suggested by Valuater, in it's current config I get the error: $yyyymd=$t^Error Subscript used with non array variable at this point in line four of the script.

How can I sort based on creation date and move the older files to another folder?

#include <Date.au3>

$t =  FileGetTime("E:" & "zip", 1)
$yyyymd = $t[0] & "/" & $t[1] & "/" & $t[2]
$iDateCalc = _DateDiff( 'd',$yyyymd,_NowCalc())

$tosearch = "E:"
$output = FileOpen("c:\filelist.txt",2)
$start = TimerInit()
RecFileSearch($tosearch)
FileClose($output)
MsgBox(0,"done","it only took " & int(TimerDiff($start)/1000) & " seconds")
Func RecFileSearch($current)
    Local $search = FileFindFirstFile($current & "\*.*")
    While 1
    Dim $file = FileFindNextFile($search)
    If @error Or StringLen($file)<1 Then ExitLoop
    FileWriteLine($output,$current & "\" & $file & "  zip  " & FileGetSize($file))
    If StringInStr(FileGetAttrib($current & "\" & $file),"D") And ( $file <> "." Or $file <> ".." ) Then RecFileSearch($current & "\" & $file)
    WEnd
    FileClose($search)
EndFunc

Share this post


Link to post
Share on other sites

the error is because file E:zip doesn't exists so FileGetTime() ends in error that should be tested for.

here is a link to a script i posted in 2004 which you can modify for your use. it also does recursive search ..


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, I was on your page earlier today looking at your findfiles.au3 script. I have adapted that for another use. The script you point me to will work, if I can modify it to archive the files rather then delete them. Also, you mention that it requires datenew.au3 include library which doesn't appear to be on your autoit page. Has that been incorporated into the latest version of AutoIt?

Share this post


Link to post
Share on other sites

Thanks, I was on your page earlier today looking at your findfiles.au3 script. I have adapted that for another use. The script you point me to will work, if I can modify it to archive the files rather then delete them. Also, you mention that it requires datenew.au3 include library which doesn't appear to be on your autoit page. Has that been incorporated into the latest version of AutoIt?

The text says datenew.au3, but when you look in the script you see I changed that a while ago to date.au3.

The datenew.au3 was at that time a propotype version of the current date.au3.


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

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