I want to create a batch file that will rename files from a folder my adding a different suffix to each file An example would be like this,
to these
I am hoping to put all these words in the batch file but putting it in a separate txt file would be more preferable
Note: I will put the same number of suffix in the txt file as there are files on the folder.
I just want a faster way of adding these suffix than doing it one by one manually
I have limited knowledge about these codes
The program below rename the files in the order given by dir
command with the suffixes given in suffixes.txt
file. If there are more files than suffixes, the last suffix will be used several times.
@echo off
setlocal EnableDelayedExpansion
< suffixes.txt (
for /F "delims=" %%a in ('dir /B folder\*.*') do (
set /P suffix=
ECHO ren "%%~Fa" "%%~Na !suffix!%%~Xa"
)
)
For example:
C:\> type suffixes.txt
sandwich
hot dog
apple
toast
C:\> test.bat
ren "file1.mp4" "file1 sandwich.mp4"
ren "file2.mp4" "file2 hot dog.mp4"
ren "file3.mkv" "file3 apple.mkv"
ren "file4.mkv" "file4 toast.mkv"
If the ren
commands looks correct, remove the ECHO
part in the last command in order to execute the ren
commands.