stlcomptchr Posted June 9, 2008 Posted June 9, 2008 Hi. I'm quite new to AutoIt. I'm looking for a script that will allow me to open file, save as with an incremental name, close the file; then open it again, save w/incremental name, close. For example: Open File1 Save as File2 Open File2 Save as File3 Open File3 Save as File4. My guess is there is a script "out there" that does this. Can anybody guide me there? Thanks!
torels Posted June 9, 2008 Posted June 9, 2008 (edited) $numberOfFiles = 10 $dir = "C:\directory\of\your\file" filechangedir($dir) $file = "file1.txt" for $i = 0 to $numberOfFiles fileCopy($file,"file" & $i & ".txt") $file = "file" & $i & ".txt" next should work Edited June 9, 2008 by torels Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org
nobbe Posted June 10, 2008 Posted June 10, 2008 (edited) $numberOfFiles = 10 $dir = "C:\directory\of\your\file" filechangedir($dir) $file = "file1.txt" for $i = 0 to $numberOfFiles fileCopy($file,"file" & $i & ".txt") $file = "file" & $i & ".txt" next wont work since file2.txt exists, it wont be overwritten if you use it with flag 1 (overwrite) then the effect is to copy file1 -> file2 -> file3 ----> file : now all files will have the same content as file 1 ! @stlcomptchr please specify if all files previously exist, or if you have some kind of logging system which should keep up to x files for backup, to keep e.g. up to x instances of a file? the trick is to count backwards, not forwards so the code would be something like this $numberOfFiles = 10 $file = $numberOfFiles & ".txt" for $i = $numberOfFiles to 1 step - 1 $j = $i + 1 $sourcefile = @ScriptDir & "\" & $i &".txt"; $destfile = @ScriptDir & "\" & $j &".txt"; $rc = FileMove($sourcefile, $destfile ,1 ) next Edited June 10, 2008 by nobbe
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now