Jump to content

Renaming 78 files...


 Share

Recommended Posts

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 >_<

Link to comment
Share on other sites

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 :(

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by Paulie
Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...