• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need to rename 400 files

rubix

Golden Member
I have 400 files named like:

BookTitle - LastName, FirstName.ext

I want them all to be:

LastName, FirstName - BookTitle.ext

Are there any programs that can do this?
 
Two steps at the command prompt:

for %a in (*.ext) do @echo %~na >>files.lst

for /f "tokens=1,3,4" %i in (files.lst) do @ren "%i - %j %k.ext" "%j %k - %i.ext"

First, verify that files.lst does not exist.

This only works if there are no spaces in the BookTitle, First or Last names and there is a space before and after the -. If not, you can experiment with delim= option.

Of course, test this on a copy of the directory (or subset of) that contains the .ext files.

ren can be changed to echo for testing.
 
Thanks. Who knows if it benefited the op.

I always wanted to play around with the expanded for syntax and had some time sunday morning. It's a weird implementation coming from unix but then it is ms...

I've heard that a directory tree can be traversed recursively with the for cmd. That'll be fun to play with. Knowing how to do this could come in handy some day.

Although it's painful, I want to be able to do things with just the basic windows install (no additional apps/utilities installed) if necessary.
 
seemingly random batch file for the win! Impressive, I would I have used perl but to each their own and your way doesn't require the OP to install perl.
 
Originally posted by: zebano
seemingly random batch file for the win! Impressive, I would I have used perl but to each their own and your way doesn't require the OP to install perl.
Yeah, there are easier ways to accomplish this - but where's the challenge in taking the easy route?
 
Back
Top