how can i batch rename the files from folder A which contains subfolders and files with this format name filename_ex.doc and make them look like filename.doc?
i’ve been trying to do this for awhile now and it’s been an epic fail. please help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I presume you want to rename the files in the subfolders as well, which is where you had problems with the direction in your 2nd comment to Martin James. I’m guessing you tried that code with the DIR /S option. But you were so close 🙂 You just needed to use 2 loops!
Edit – fixed code Once the output looks correct, drop the ECHO to make it functional.
The above will work as long as each file name does not have any
_or.other than what appears in_ex.ext. Characters in the path should not be any problem, just the file name is a concern.Here is a more robust solution that should work with any filename (except unicode names). It is also significantly faster. It uses a substring operation, and you must know the number of characters to strip from the name. In your example it is 3 characters. Again, remove ECHO once the resultant commands look correct.