8

I have multiple files in a folder all the different name in windows with common suffix say _(new). Example:

File Name_(new).mp4

How do I rename all the files by removing the suffix _(new) but not changing the name of the files?

Maroof Mandal
  • 183
  • 1
  • 1
  • 7
  • Simple solution using [JREN.BAT renaming utility](http://www.dostips.com/forum/viewtopic.php?t=6081) (pure script): `jren "_\(new\)\.mp4$" ".mp4" /i` – dbenham Sep 21 '16 at 14:17

1 Answers1

1

Running the REN or RENAME command in Command Prompt should work for you:

Assuming the type is always .mp4:

RENAME *_(new).mp4 *.mp4

Otherwise, the following should work:

RENAME *_(new).* *.*

First, you want to CD into the folder it's in.

If you start your computer normally, CMD should put you in your user folder, e.g:

C:\Users\Macraze

or it might put you in the system32 folder:

C:\windows\system32

Either way, you can CD into the folder you want by typing something like:

C:\Users\Macraze> CD Downloads
//whoops, wrong folder, you can just 'CD ../' out
C:\Users\Macraze\Downloads> CD ../
C:\Users\Macraze> CD Desktop
C:\Users\Macraze\Desktop> CD Misc
C:\Users\Macraze\Desktop\Misc> RENAME *_(new).* *.*

When you run this command, the asterisk * is called a wildcard, meaning all content that matches the rule of having _(new). in between the filename / extension will get renamed.

Quill
  • 308
  • 2
  • 10
  • how do I specify the folder? Would the prompt rename all files in my computer? – Maroof Mandal Aug 24 '15 at 14:19
  • No, CMD will start in a specific folder and you can CD into a specific folder (and CD ../ out), or drag the folder icon into CMD after CD to specify the folder – Quill Aug 24 '15 at 21:21
  • Input example @MattFrear? – Quill Jan 20 '16 at 16:02
  • @MattFrear try my update – Quill Jan 20 '16 at 16:07
  • C:\Users\mattf\Desktop\Stored Procedures>dir /b CollectionPointProviderDeliveryOptionTypeCountryExportSelect.sql CollectionPointProviderExportSelect.sql CountryDutyExportSelect.sql CountryExportSelect.sql CountrySubscriptionExportSelect.sql C:\Users\mattf\Desktop\Stored Procedures>RENAME \*_(new).\* \*.\* The system cannot find the file specified. C:\Users\mattf\Desktop\Stored Procedures> – Matt Frear Jan 21 '16 at 16:48
  • @MattFrear probably because the author of the question is talking about renaming files being suffixed with `_(new)`, your files aren't. – Quill Jan 21 '16 at 22:33
  • 4
    It makes no sense for this answer to be accepted. The proposed command has absolutely no effect, and it certainly does not answer the question. – dbenham Sep 02 '16 at 14:23
  • 1
    @dbenham, then add an answer. Vandalising the post is immature and childish. – Quill Sep 02 '16 at 16:37
  • @Quill - I did not vandalize the answer - I added factual information without making any judgment. Had the question not been closed, then I would have provided my own answer, and included information as to why your answer is wrong. I chose to edit your answer and add a disclaimer at the top because I am afraid many readers will not read late arriving comments, and your answer can lead unsuspecting readers down the wrong path, as evidenced by 5th comment at http://superuser.com/q/1120265/109090. I suggest you test your code and prove to yourself it doesn't work, and then delete your answer. – dbenham Sep 02 '16 at 17:28
  • For an explanation of why a simple REN command cannot solve this problem, see http://superuser.com/q/475874/109090 – dbenham Sep 02 '16 at 18:04
  • 4
    Here, this disgusting monstrosity will work: `cmd /V:ON /s /c "set "suffix=_(new)" && set "ext=mp4" && for /F "delims=" %F in ('dir /B "*!suffix!.!ext!"') do @(set "_tmp=%F" && cmd /s /c "rename "%_tmp%" "%_tmp:!suffix!=%"")"` Just change the "suffix=_(new)" and "ext=mp4" parts to whatever you need. If you want to see it without it actually doing it just add an `echo` statement before the `rename` It's all inclusive and turns on delayed expansion with the `/v:on` which contributes, a lot, to why it's so ugly. If put in a batch file make sure to use %%F instead of %F. – Brent Rittenhouse Nov 13 '18 at 03:05
  • @Quill, what if it were a prefix: such as New_Filename.ext -> Filename.ext – AAA May 31 '19 at 18:05
  • **what if the filenames contain spaces?** For example, the following does not seem to be working: `ren "Part with spaces-"*.txt "Desired new part"*.txt` – oldboy Jul 20 '21 at 23:21
  • 3
    Something seems to have changed. `RENAME *_(new).mp4 *.mp4` does nothing for me for the file `File Name_(new).mp4` on Windows 10 21H1 – Paul B. Sep 02 '21 at 09:08
  • Does not work for me either. – yaugenka May 29 '22 at 17:56