Skip to content

Instantly share code, notes, and snippets.

@Daniel-Wiedemann
Created April 3, 2014 13:43
Show Gist options
  • Save Daniel-Wiedemann/9954599 to your computer and use it in GitHub Desktop.
Save Daniel-Wiedemann/9954599 to your computer and use it in GitHub Desktop.
Windows Command Line
To add a prefix to filenames in an folder.
1. open the command line window
2. go into the folder where are the files to add the "_prefix"
3. FOR /r "." %a in (*.*) DO REN "%~a" "prefix%~nxa"
You can also define which files should get prefixed
eg. only .txt files
FOR /r "." %a in (*.txt) DO REN "%~a" "prefix%~nxa"
To add a suffix to filenames in an folder.
1. open the command line window
2. go into the folder where are the files to add the "_suffix"
3. for %a in (*.*) do ren "%~a" "%~na_suffix%~xa"
You can also define which files should get suffixed
eg. only .txt files
for %a in (*.txt) do ren "%~a" "%~na_suffix%~xa"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment