• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Steps to batch rename files

Page history last edited by Monica 11 years, 4 months ago

General

basic command is ren file1 file2

OR for files across nested folders ren path+file1 file2

create a *.bat file to batch rename all files

for files that have subfolder arrangement, include file path for old file name (file1)

 

tip: if spaces exist in filename must wrap filename within quotes

 

Steps

  1. Open a Command Prompt window at your desired location : hold Shift, right-click in the folder, and select “Open command window here.”

  2. Extract all filenames include path if needed:

    1. When files are all in the same directory use command: dir /b >changename.bat and press Enter

    2. For nested subfolders use command: dir /s /b /a-d >changename.bat and press Enter

  3. Goto NotePad and Open changename.bat (change file types to view all)

  4. From the menu select Edit>Select all, then Edit>Copy or press keys control + C

  5. Goto Excel, paste data (may need to use text import wizard so data is not auto parsed)

  6. Remove any files you do not wish to rename (e.g. thumbs.db)

  7. Insert column to left, enter “ren” for all rows

  8. In column to right of filenames, enter new filenames (see below for tips on converting filenames)

  9. Select entire range (3 columns) and Copy

  10. Toggle back to changename.bat in NotePad

  11. Replace all lines: Edit>Select all>Paste

  12. Save and close file changename.bat

  13. Toggle back to command prompt and enter : changename.bat and press Enter

 

Figure 1: Command line Window: Extract filenames with path

 

 

Examples

You may use various features/formulas in Excel formulas to create new filenames. Below are two examples

 

Example: change case to all lower case

Eg from MSS58600005R.tif to ms58600005r

 

  1. Open changename.bat in excel

  2. Insert column to left, enter “ren” for all rows

  3. In next empty column insert formula =lower(B1)

  4. Copy and paste formula for all rows of data

  5. Select entire range (3 columns) and Copy

  6. Paste into changenames.bat file, save and run batch

 

Example: Use subfolder name as prefix to existing filename

Eg from 0005.tif to thr1916012901_0005.tif

 

  1. Open changename.bat in excel

  2. Insert column to left, enter “ren” for all rows

  3. Parse out data

  • Selection column of existing filenames

  • From the Data menu, on the Data Tools Panel, select Text to columns

  • Wizard will appear. Select Delimited file type and press Next

  • Place a check mark next to the Other box and enter a back slash “\” as the deliminator and press Next

  • In Destination, enter the cell reference for the next first empty column (eg C1) in your spreadsheet and press Finished

 

This will parse out data into separate columns. Remove any columns you do not need

  • In this case, keep data for subfolder name which will be used to generate new filename

  • Column “ext” is formula (=right(B2,3). It is used only to help sort files and identify which ones do not need to be renamed (e.g. thumbnails)

 

  1. Create new filename, using concatenate function:

 

Where New Filename is

=CONCATENATE("thr",F2,"_",G2)

Where F2 = folder name (eg 1913012901)

G2 = filename

 

 

  1. Select entire range (3 columns) and Copy

  2. Paste into changenames.bat file, save and run batch

 

 

Comments (0)

You don't have permission to comment on this page.