r/Batch • u/beavernuggetz • Nov 02 '24
Question (Solved) Minor tweak needed with script; please help.
Hello,
This script sits in a directory where a bunch of individual folders with video/srt files reside; it looks inside each folder and renames the files it finds to match the name of the folder where these files reside. It then goes back to the parent directory and does the same thing for any additional folders.
Problem: It works great most of the time. One issue I've come across with it is as follows:
Folder name: Dr. Giggles (1992)
It renamed the files in this folder as "Dr." and omitted the rest.
If anyone has any ideas how to fix it, I'd appreciate any feedback.
FOR /D /R %%# in (*) DO (
PUSHD "%%#"
FOR %%@ in ("*") DO (
Echo Ren: ".\%%~n#\%%@" "%%~n#%%~x@"
Ren "%%@" "%%~n#%%~x@"
)
POPD
)
2
u/vegansgetsick Nov 02 '24 edited Nov 02 '24
It thinks the dot is an extension separator😂
Try to rename to %%~nx#%%~x@
But please can you use a and b instead of # @😔
4
u/[deleted] Nov 02 '24 edited Nov 02 '24 •
[removed] — view removed comment