Adding prefix to all filenames in folder
Adding a prefix to all filenames in a directory from Windows Command Prompt. Only to filenames, not to folder names as well:
FOR /F "TOKENS=*" %G IN ('DIR /B /A-D') DO REN "%G" "PREFIX%G"
Code for .BAT file:
@ECHO OFF
FOR /F "TOKENS=*" %%G IN ('DIR /B /A-D') DO (
REN "%%G" "PREFIX%%G"
)
Note: enter your prefix instead of PREFIX.
Adding prefix only to filenames of specific type
Prefixing only .htm and .jpg files for example:
FOR /F "TOKENS=*" %G IN ('DIR /B /A-D *.htm *.jpg') DO REN "%G" "PREFIX%G"
Code for .BAT file:
@ECHO OFF
FOR /F "TOKENS=*" %%G IN ('DIR /B /A-D *.htm *.jpg') DO (
REN "%%G" "PREFIX%%G"
)
Note: enter your prefix instead of PREFIX.
Operating systems
- Windows