Jump to content

Looking for software that can batch rename a 1000 files according to txt

Jurand

Hey, i have a lot of randomly named files (like e74491ee, 2aa12e80, b6b2888e, 6bb1855e etc) and i have a text template how they should be named (example e74491ee should be named File1, 6bb1855e File2, 2aa12e80 File3 etc). Is there some kind of a utility that could automagically rename the files according to values specified in text file?

Link to comment
Share on other sites

Link to post
Share on other sites

This should be fairly easy to do with some scripting.

Do I understand you correctly, the files have pretty random names, but you got a text file that lists how they should be renamed. Correct?

 

Can you please show post a snippet of the text file so that we can see how it is formatted?

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, LAwLz said:

This should be fairly easy to do with some scripting.

Do I understand you correctly, the files have pretty random names, but you got a text file that lists how they should be renamed. Correct?

 

Can you please show post a snippet of the text file so that we can see how it is formatted?

Thats right, txt looks like this: 

Untitled.png

Link to comment
Share on other sites

Link to post
Share on other sites

22 minutes ago, Jurand Ze Spychowa said:

Hey, i have a lot of randomly named files (like e74491ee, 2aa12e80, b6b2888e, 6bb1855e etc) and i have a text template how they should be named (example e74491ee should be named File1, 6bb1855e File2, 2aa12e80 File3 etc). Is there some kind of a utility that could automagically rename the files according to values specified in text file?

Dont know if this is useful but if you download Microsoft Powertoys, theres a great rename tool for multiple files called PowerRename: https://github.com/microsoft/PowerToys/releases/tag/v0.61.1

CPU: Ryzen 5800X3D | Motherboard: Gigabyte B550 Elite V2 | RAM: G.Skill Aegis 2x16gb 3200 @3600mhz | PSU: EVGA SuperNova 750 G3 | Monitor: LG 27GL850-B , Samsung C27HG70 | 
GPU: Red Devil RX 7900XT | Sound: Odac + Fiio E09K | Case: Fractal Design R6 TG Blackout |Storage: MP510 960gb and 860 Evo 500gb | Cooling: CPU: Noctua NH-D15 with one fan

FS in Denmark/EU:

Asus Dual GTX 1060 3GB. Used maximum 4 months total. Looks like new. Card never opened. Give me a price. 

Link to comment
Share on other sites

Link to post
Share on other sites

You can make a batch file with the rename commands  ex RENAME  "original name.mp4"  "new name.mp4"  

 

So you need to have that 123354.mp4 BEFORE  the Odcinek 7;   basically you want  

 

Odchinek 7;1234.mp4 

 

to become 

 

RENAME "1234.mp4"  "Odchinek 7.mp4"

 

You could start by abusing Excel's import text feature.  Use import text, select your text , if needed specify UTF-8 as code page, tell it to separate columns by the ; character 

 

image.png.a7247e3e08a9c8c47a96a9028ad84c21.png

 

The import wizard looks a bit different in newer versions , this is office 2013 I think 

 

image.png.0a5c2aed39b267ed502a3a3e3666328e.png

 

Uncheck the default  Tab, and select Other, and type the ; character

 

image.png.05a2e3d62d11c8e2ce0ca6cf5752b14e.png

 

Hit next and finish and you'll have two columns in excel

 

image.png.b3b83948f244bdedfdfa54b4bf4ba730.png

 

now you can select the whole A column , right click on A select CUT and paste it on column D (right click on D, paste)

You want to leave one column empty because you'll add something there. 

 

image.png.eb95c98c50be39781482bd88c01a6832.png

 

Now you want to put the rename " (rename, space, " )   in front, in column  A , and you want  " "  (quote, space , quote) in column C, and  .mp4"  in column E

You only need to type those on first row, then move mouse in the corner of the cell and drag it down to the last entry, and Excel will auto fill the whole column. 

 

image.png.c84c18983e62be36a73461ae3d1330ce.png

 

And now you can export your spreadsheet into the new text file, but we'll use NO separator, or if we have to we use TAB or some unique combination of characters as column separator, because we'll want to remove this separator from the text file

I'll use TAB because I can then easily search for these characters with Notepad++ and replace them or delete them 

 

image.png.9067a11a81d15f8f301132c539ec54af.png

 

 

So we save the text file in Notepad++ and if I check  View > Show Symbol > Show spaces and TABs I can see them in the text file easily : 

 

image.png.c000dcfaa44a76b73eed6acbf8e912d2.png

 

Excel puts  " " around each column, so we'll have to get rid of the excess  quotes. 

Use the search and replace function  

 

Search for  "" replace with " , replace all , repeat as many times as needed 

 

image.thumb.png.39f94b3bb84a407c0ca8a494cd2c0981.png

 

Remove the " from before the rename  :  search for "rename  , replace with rename 

 

Now you want to remove the TAB characters ... make sure Extended mode is checked in search and replace, type  \t (code for TAB) in find, enter nothing in replace, and select replace all : 

 

image.thumb.png.a0c4538094be1fcf0d26c1130fe7c1a1.png

 

Now there's only one more issue, the " that's in front of the .mp4"  ... so you can do a search for ".mp4"  and replace with .mp4 :

 

image.thumb.png.d92d497d2f1e4cc7cca7f5ff942a6c69.png

 

Now you can simply save this text file with the .BAT extension in the same folder where you have the files, double click it, and all the files will be renamed. 

 

make a backup of the files first though. 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

@mariushm

Could just open the txt file in notepad++ and do regular expression to get the same end result

 

Ctrl+H change search mode as regular expression and set

"Find what:" field as  ^([^;]+);([^\.]+)\.mp4

"Replace with:" field as rename "$2.mp4" "$1.mp4"

Click Replace All button

 

Link to comment
Share on other sites

Link to post
Share on other sites

Both solutions indeed gave the same result 🙂 My files are now named correctly, thank You very much!

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×