The following command only changes the name of the files but not the folders.
for %a in (*) do ren "%a" "00_%a"
The following command only changes the name of the files but not the folders.
for %a in (*) do ren "%a" "00_%a"
for %a in (*) do ren "%a" "00_%a"
Notes:
for as above is not advised.Use the following in a cmd shell:
for /f "tokens=*" %a in ('dir /b') do ren "%a" "00_%a"
In a batch file (replace % with %%):
for /f "tokens=*" %%a in ('dir /b') do ren "%%a" "00_%%a"
Note:
It is critical that you use
FOR /Fand not the simpleFOR.The
FOR /Fgathers the entire result of theDIRcommand before it begins iterating, whereas the simpleFORbegins iterating after the internal buffer is full, which adds a risk of renaming the same file multiple times.
as advised by dbenham in his answer to add "text" to end of multiple filenames:
To perform this For loop on folders (directories) instead of files, simply include the /D switch.
for /D %a in (*) do ren "%a" "00_%a"
From for /?:
FOR /D %variable IN (set) DO command [command-parameters]
If set contains wildcards, then specifies to match against directory names instead of file names.