How to rename multiple files by adding or removing suffix or prefix in windows?

6

3

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

Posted 2015-08-24T13:30:49.773

Reputation: 163

Question was closed 2015-08-29T01:33:43.910

Simple solution using JREN.BAT renaming utility (pure script): jren "_\(new\)\.mp4$" ".mp4" /i

– dbenham – 2016-09-21T14:17:40.970

Answers

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

Posted 2015-08-24T13:30:49.773

Reputation: 300

how do I specify the folder? Would the prompt rename all files in my computer? – Maroof Mandal – 2015-08-24T14:19:06.933

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 – 2015-08-24T21:21:46.477

Input example @MattFrear? – Quill – 2016-01-20T16:02:51.973

@MattFrear try my update – Quill – 2016-01-20T16:07:38.953

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 – 2016-01-21T16:48:42.073

@MattFrear probably because the author of the question is talking about renaming files being suffixed with _(new), your files aren't. – Quill – 2016-01-21T22:33:51.690

4It 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 – 2016-09-02T14:23:54.050

1@dbenham, then add an answer. Vandalising the post is immature and childish. – Quill – 2016-09-02T16:37:24.757

@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 – 2016-09-02T17:28:42.040

For an explanation of why a simple REN command cannot solve this problem, see http://superuser.com/q/475874/109090

– dbenham – 2016-09-02T18:04:27.753

3Here, 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 – 2018-11-13T03:05:04.400

@Quill, what if it were a prefix: such as New_Filename.ext -> Filename.ext – AAA – 2019-05-31T18:05:38.067