Use a list like "Old Name = New Name" to batch rename folders?

Discussion in 'other software & services' started by paulescobar, Jan 18, 2009.

Thread Status:
Not open for further replies.
  1. paulescobar

    paulescobar Registered Member

    Joined:
    Sep 22, 2008
    Posts:
    181
    I have 190 folders.
    They have very generic names that need changing..

    Folder1
    Folder2
    Folder3
    etc.


    I have a text file containing a list.
    It's structured as "Old Name = New Name".

    Folder1 = Security
    Folder2 = Controls
    Folder3 = Processing
    etc.


    Can I use this list to batch rename my folders?
    Can you suggest a software that can take advantage of my list?
     
    Last edited: Jan 19, 2009
  2. Sully

    Sully Registered Member

    Joined:
    Dec 23, 2005
    Posts:
    3,719
    Easiest for beginners IMO would be AutoIt. Forums are full of examples and help. Help file has examples. Compilable. Can have a GUI if you want.

    What you want to do, basically, is create your list, maybe like this

    OldName=NewName
    OldName1=NewName1

    Then you would read this file into an array, so that you now have a 'table' with one column
    [column 1]
    OldName=NewName
    OldName1=NewName1

    Then you go to the directory where your folders are located, and start processing it. So, you would find the first directory, like OldName. You would then step through the array (table), looking for a text match, something like

    $name = 'OldName' (whatever it may be)
    for $x = 1 to Ubound($yourArray) ; this is the 'table' made from the text file
    If StringInStr($yourArray[$x],$name) Then
    ; you have found a match, so you would need to get the new name
    $newname = ;you could use either stringsplit or stringtrimleft or stringright
    FileRename($name,$newname)
    EndIf
    Next

    This is generic and meant to give you some pointers, but with AutoIt, there are enough examples and threads in the forum it should not take too long.

    You could do it with batch, but takes a little more syntax understanding. You could also do it with vbs without much difficulty as well. I would think those would be the 3 easiest for a beginner.

    Sul.
     
  3. paulescobar

    paulescobar Registered Member

    Joined:
    Sep 22, 2008
    Posts:
    181
    Thanks for your detailed response Sully!
    It's much appreciated.

    I'll give AutoIt a try. :)
     
Loading...
Thread Status:
Not open for further replies.