4

I have a large (aprox. 150,000) tiff files which all have the same filename. They are unique because of the directory structure they are held in.

I would like to bulk rename the tiff files so they become unique, based on the directory structre that they are held within.

Does anyone have any method of acheiving this?

I am using Windows Server 2012 so a solution using a cmd script, batch file or windows GUI tool would be perfect.

Ideally, this is what I would like to acheieve, but if I have to have more or all of the directory structure in the final filename thsi would still be very, very helpful.

C:\A_001\B_0001\ABC\0001.tif -> ABC.tif

C:\A_001\B_0001\JKL:\0001.tif -> JKL.tif

C:\A_001\B_0001\XYZ\0001.tif -> XYZ.tif

C:\A_001\B_0002\123\0001.tif -> 123.tif

C:\A_001\B_0002\456\0001.tif -> 456.tif

C:\A_001\B_0002\789\0001.tif -> 789.tif

1
  • 1
    Super User is not a script writing service. It would improve your question if you shared what you've done on your own so far, post your code and where you have gotten stuck. This is the best method for use to help you, other than doing it for you.
    – CharlieRB
    Nov 6, 2014 at 13:36

2 Answers 2

3

In Bulk Rename Utility, set 'Append Folder Name' to 'Prefix' or 'Suffix' and optionally, add a separator character (Sep.) and set 'Levels' to how many directories above the file should be included in its new filename.

screenshot of Bulk Rename Utility's UI configured as described above

You could use its other renaming features, e.g. 'Remove', 'Replace', 'RegEx', to further modify the original files' filenames.

2
  • 1
    1/2 This tool is great - thank you. I'm doing an inventory of physical photos & their scanned counterparts that I got a company to do for me because there were thousands. The photos have come back in folders that match the batches I gave them over time. To link each photo to its scanned counterpart, I'm making a unique filename to act as an id from the photo filename AND its 2 parent folders. The photo filename within each folder is just a date of scan & an incremental no. - itself is a count within the folder, so not unique, but prefixing parent folder names to the filename makes it unique... Mar 1 at 1:19
  • 1
    2/2 ...then with each photo file now having a unique filename as identifier. I am going to create a text file the list of all of them. This text file will be imported into a excel file which I will then feed into label print software to print a label to stick on the back of each photo. Brother P-touch label printer and software (no affiliation) The end result is that for any physical photo, the equivalent digital scan can be found. Mar 1 at 1:19
2

You can easy do it with VBScript like this (not tested!):

Const cRootDir = "here_to_start"
Const sFileToRename = "here_to_rename"
Set Fso = CreateObject("Scripting.FileSystemObject")
Dim oRootDir : Set oRootDir = Fso.GetFolder(cRootDir)

For Each subfolder In oRootDir
   For Each oFile in subfolder.Files
     If oFile.Name = sFileToRename  Then Fso.MoveFile oFile, subfolder & ".tif"
   Next
Next

You can start this script with

cscript.exe myScript.vbs

1
  • 1
    You should test it...
    – Ludwik
    Nov 6, 2014 at 10:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .