Hyflex Posted August 25, 2009 Posted August 25, 2009 I have: fu (1).rar fu (2).rar all the way upto 78 I need to rename the .rar to .r00 for the top one and then .r01 and .r02...etc How can I do this easy.. it will take foreeer doing it manually as I have in total 18 folders with 78 .rar's in >_<
PsaltyDS Posted August 25, 2009 Posted August 25, 2009 I have: fu (1).rarfu (2).rarall the way upto 78I need to rename the .rar to .r00 for the top one and then .r01 and .r02...etc How can I do this easy.. it will take foreeer doing it manually as I have in total 18 folders with 78 .rar's in FileMove() in a For/Next loop. >_< Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Hyflex Posted August 25, 2009 Author Posted August 25, 2009 FileMove() in a For/Next loop. >_<Thanks buddy, will try asap (when i get a tad of time )
Hyflex Posted August 25, 2009 Author Posted August 25, 2009 You were on about: http://www.autoitscript.com/autoit3/docs/functions/FileMove.htm ??? I dont understand how can that change the file name and I don't know how to make it increment per file.. so $filename ($increment1).r + $increment2 So: fu (1).r01 fu (2).r02 fu (3).r03 fu (4).r04 ...etc
Paulie Posted August 26, 2009 Posted August 26, 2009 (edited) Heres a quick and dirty. You might have to adjust for different dirs and such, but this'll get you started. $Directory = "C:\Directory\Files\" ; change this to the directory $ext1 = ".rar" For $x = 0 To 78 $Filename = "fu (" & $x & ")" $ext2 = ".r" & PadDigits($x, 2) FileMove($Directory & $Filename & $ext1, $Directory & $Filename & $ext2) MsgBox(0, "", "Moved" & @CRLF & $Directory & $Filename & $ext1 & @CRLF & "To" & @CRLF & $Directory & $Filename & $ext2);Debug line Next Func PadDigits($num, $len, $Char="0") $Result = String(abs($num)) $Count = $len - Stringlen($Result) For $a = 1 to $Count $Result = $Char & $Result Next Return $Result EndFunc ;==>PadDigits Edit: Re-tidy'd the code Edited August 26, 2009 by Paulie
99ojo Posted August 26, 2009 Posted August 26, 2009 Heres a quick and dirty. You might have to adjust for different dirs and such, but this'll get you started. $Directory = "C:\Directory\Files\" ; change this to the directory $ext1 = ".rar" For $x = 0 To 78 $Filename = "fu (" & $x & ")" $ext2 = ".r" & PadDigits($x, 2) FileMove($Directory & $Filename & $ext1, $Directory & $Filename & $ext2) MsgBox(0, "", "Moved" & @CRLF & $Directory & $Filename & $ext1 & @CRLF & "To" & @CRLF & $Directory & $Filename & $ext2);Debug line Next Func PadDigits($num, $len, $Char="0") $Result = String(abs($num)) $Count = $len - Stringlen($Result) For $a = 1 to $Count $Result = $Char & $Result Next Return $Result EndFunc ;==>PadDigits Edit: Re-tidy'd the code Hi another solution: #include <file.au3> $Directory = "C:\Directory\Files" ; change this to the directory $files = _FileListToArray ($Directory, "*.rar", 1) For $x = 1 To UBound ($files) - 1 $filename = StringSplit ($files [$x], ".") If $x < 10 Then FileMove($Directory & "\" & $files [$x], $Directory & "\" & $filename [1] & ".r0" & $x) Else FileMove($Directory & "\" & $files [$x], $Directory & "\" & $filename [1] & ".r" & $x) EndIf Next ;-)) Stefan
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