Topic: Capitalize folder names

In order to capitalize names of a whole directory tree
I use this command line

-d FolderPath -t -s * -e %Lf -r -q

This does capitalize the file name in the root dir and its subdirs smile
but not the names of the dirs themselves. sad

How can I include dir names in the renaming process ?


Thanks for your help


Pierre

Re: Capitalize folder names

Hello,

The directories can't be renamed in "sub-directories loading" mode (recursion).
You can see this clearly when using the user interface : directories don't have checkboxes.
This is explained in the FAQ : Loading sub directories

Sorry ...

Re: Capitalize folder names

Un jour peut-être ?   roll

4 (edited by Stefan 2012-06-13 20:09:11)

Re: Capitalize folder names

Maybe DOS Batch to the aid?

What do you think Rémi? Would that work?

WARNING: this will only work (if then) to change the case of the folder names.
If you would change parts of the name, the path to the sub-folder would not be valid anymore.
We had to modify from the deepest sub-folder to the top folder then.
Should be doable too by reversing the list, but that trick i will only provide if it would work anyway at first :-)



What i had in mind was:

* go to the folder

* get the list of sub-folders:
X:\folder>dir /AD /B /S > Folders.txt

or for english windows
X:\folder>dir /AO /B /S > Folders.txt

(In an DOS-Box use "DIR /?" for an help)




* For Each Folder in Folders.txt run an test:
FOR /F "tokens=*" %D IN ('type Folders.txt') DO @ECHO "%D"
or in an Batch use double %s:
FOR /F "tokens=*" %%D IN ('type Folders.txt') DO @ECHO "%%D"

This should echo the whole path of the sub-folders incl. quotes.

Another example btw:
Use %~nD  to only see the name-part of the sub-folders. for example.
FOR /F "tokens=*" %%D IN ('type Folders.txt') DO @ECHO %%~nD

(In an DOS-Box use "FOR /?" for an help)




* if it works try it with Siren:
FOR /F "tokens=*" %%D IN ('type Folders.txt') DO (
    ...here your Siren command line,  "%%D" will insert one folder name after the other in each loop...
)





umm, an batch again.  .... i should really switch to  powershell  ;-)
Or we can do this by an VBS or JS script...
.

Re: Capitalize folder names

Yes, a DOS batch file can maybe do the trick.

Something like (I surely missed things) ? :

  • dir /AD /B /S %1 | sort /R : to get the directory tree names in reverse order

  • a "FOR" to parse the result

  • execute some code explained here to change the case of the name

  • execute the "REN"

Maybe this batch could be used as a "Tool" in Siren. After execution the directory should have to be reloaded.

It could be easier to use another "language", no ?

Re: Capitalize folder names

Ahh, i thought i can use Siren inside the FOR loop to rename the folders.

For Each %D In Folders (
    launch Siren.exe to rename %D
)

No?

-

But just for "to capitalize names of a whole directory tree" an Visual Basic or Java Script will do.
It's better in handling code pages too for non-english (non-ASCII 7) names then an batch.
That can be done by utilizing the FileSystemObject.

I am not an coder, but something like this should work:

TEST WITH COPIES OF YOUR FILES ONLY  smile

'Rename all Folder and/or files to lower or upper case
'=======================================================


'USER SETTINGS:
'sPath is top folder to start the renaming
'sCase is an switch to change case to UPPER or lower case
sPath = "c:\TEMPO\Test vbs rename\"
sCase = "UPPER"


'Call the renaming:
RecurseFolders sPath, sCase
MsgBox "Finished"


'THE CODE:
Sub RecurseFolders(sPath, sCase)
    IF (LCASE(sCase) <> "lower" AND LCASE(sCase) <> "upper") Then
      MsgBox "Please use ""lower"" or ""upper"", but not """ _
              & sCase & """ !" & vbCRLF & "Script end here."
      Exit Sub
    End IF
    
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set FLDs = FSO.GetFolder(sPath)
    
    For each folder in FLDs.SubFolders
      Set oFldr = FSO.GetFolder(folder)
      
        'RENAME FOLDERS:
          OLDname = oFldr.Name
          oFldr.Name = OLDname & "-"
          IF (LCASE(sCase) = "lower") Then oFldr.Name = LCase(OLDname)
          If (LCASE(sCase) = "upper") Then oFldr.Name = UCase(OLDname)
        
        'RENAME FILES:
         ' For Each file In oFldr.Files
         '   OLDname = file.Name
         '   file.Name = OLDname & "-"
         '   IF (LCASE(sCase) = "lower") Then file.Name = LCase(OLDname)
         '   If (LCASE(sCase) = "upper") Then file.Name = UCase(OLDname)
         ' Next
    
       IF FLDs.SubFolders.Count > 0 Then
          RecurseFolders folder.Path, sCase
       End if
    Next
End Sub

Re: Capitalize folder names

I didn't correctly read your post. Sorry.
There are different ways to solve this.