Run this from another folder, and the pushd is used otherwise the batch file will be renamed too. Change c:\mainfolder
to your main folder name
@echo off
pushd "c:\mainfolder\"
for /r %%j in (*) do (
rename "%%j" "[nilesh.uk.to]-%%~nxj"
)
popd
Frage
I am trying to add prefix to all files in current folder and it's subfolders and i made the following batch file
setlocal enabledelayedexpansion
for %%j in (*) do (
set filename=%%j
rename !filename! [nilesh.uk.to]-!filename!
)
it working for current directory only but i want to add prefix to all files in current folder as well as subdirectory please help me to solve this problem
Lösung
Run this from another folder, and the pushd is used otherwise the batch file will be renamed too. Change c:\mainfolder
to your main folder name
@echo off
pushd "c:\mainfolder\"
for /r %%j in (*) do (
rename "%%j" "[nilesh.uk.to]-%%~nxj"
)
popd
Andere Tipps
using renamer, you can do it in one command like this:
$ renamer --regex --find '^' --replace 'prefix-' '**'