This batch script allows you to rename multiple files in a folder based on new names specified in a text file. The script prompts the user for the location of the new names file and the folder containing the files to rename.
- Windows operating system
- A text file containing the new names for the files, with each name on a new line
- For safety, move the files to be named in a different folder.
-
Save the batch file (e.g.,
rename_files.bat
) in a convenient location on your computer. -
Create a text file (e.g.,
newnames.txt
) containing the new names for the files, with each name on a new line. -
Double-click the
rename_files.bat
file to execute the script. -
When prompted, enter the full path to the new names file (e.g.,
C:\path\to\your\newnames.txt
). Press Enter.- If the specified file does not exist, an error message will be displayed, and the script will exit.
-
Next, enter the full path to the folder containing the files you want to rename. Press Enter.
- If the specified folder does not exist, an error message will be displayed, and the script will exit.
-
The script will display the selected folder path. Press any key to continue.
-
Next, enter the desired file extension for the new names (e.g.,
.txt
,.pdf
,.docx
). Press Enter. -
Finally, enter the pattern of the old file names (e.g., if the file names are
report1
,report2
and so on, typereport
). Press Enter. -
The script will start renaming the files based on the new names specified in the text file, appending the chosen file extension.
- If a file matching the old name pattern does not exist, a message will be displayed indicating that the file does not exist.
-
Once the renaming process is complete, the script will pause, allowing you to review the results. Press any key to exit.
- Always create a backup of your files before running the script to prevent data loss.
- Test the script with a small set of sample data before applying it to your entire dataset to ensure it behaves as expected.
- If you encounter any issues, double-check the file paths and ensure that the new names file is formatted correctly (one name per line).
If you have any further questions or need additional modifications, feel free to ask!