I am trying to rename files in a batch script like this:
rename %FOLDER%\* 1-*
but when I run the script It overwrites the first two characters of the original names with the prefix "1-" instead of adding it to the beginning of the file names. How can I work around this?
Rename will just rename the file, you would need to call the file name as a variable after the prefix. The below is what ended up working.
cd %folder%
for %%a in (*) do rename "%%a" "1-%%a"
try this as a starting point
@echo off
for %%a in (%folder%\*) do (
echo ren "%%~fa" "1-%%~nxa"
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With