Assistance with complicated renaming task

Bulk Rename Utility How-To's

Assistance with complicated renaming task

Postby treehstn » Thu Aug 08, 2024 9:00 pm

Hi,

I'm new to BRU but have used it for several tasks successfully in the project I'm working on. This next part I'm at a loss for how to do it. I'm somewhat tech savvy but not to this level. Any help would be so appreciated!

I have thousands of files in the following format and need to change them. A little background... These are US patent files. For any given patent there will be anywhere between 1 and 12 image files. I have each patent's files in it's own directory labeled with the patent number in it's final format. It's the individual image files that I need to reformat their file names. If you look at the final file name format example below the patent number is 36399. The -001 suffix is the image number for that patent. The patent number portion of the file name should always have 7 digits which includes leading zeros. What I was able to figure out was how to replace the US with us09 and then I got a little overwhelmed after that.

US36399_1 Starting file name format
us0d0036399-001 Final file name format

Steps:

1. Replace US with us0d (I've got that figured out.)
2. Insert the correct amount of leading zeros to equal 7 digits.
3. Replace the _1 with the corresponding suffix -001, -002, -003, etc.

Step 1 above I'm comfortable with. The other 2 I'm pretty lost on. I thought if I replaced US with us0d- (with a hyphen) it would separate out the 7 digits to work with the leading zeros. But I'm really not sure where to go from there trying to figure out steps 2 & 3 above.

Caveat: I'm recovering from a very slight brain injury so I get overwhelmed when looking at really complicated screens like how the BRU screen looks. If I have a little guidance it helps a lot. It's focus and concentration that I have the most issues with. The more I work at things the better I get. This is a huge project that I can work with but this file naming issue is a really big speed bump for me and is holding up the rest of the project. I'd be so grateful for any help!

Thank you!
treehstn
 
Posts: 8
Joined: Thu Aug 08, 2024 8:37 pm

Use different padding at different places

Postby Luuk » Fri Aug 09, 2024 12:42 am

With RegEx(1) having a "v2" checkmark, the "Match" and "Replace" could be like...
^US(\d+)_(\d+ .+)(?X):0*(?=\d{7,})|/0*(?=\d{3,})/g
us0d__:0000000$1-/000$2(?X)

This can rename something like...
US12_1 Name ---------> us0d__0000012-001 Name
US12_00009 Name ---> us0d__0000012-009 Name
US36399_4 Name ----> us0d__0036399-004 Name
(If not wanting separators, can remove __ from the "Replace")


If anybody is curious, the (?X) grants RegEx(1) to conduct many different regexs, so editing like...
Original-Name -------> Insert : and / with extra 0's -------------> :Digits->7Digits, /Digits->3Digits
US12_1 Name --------> us0d__:000000012-/0001 Name --------> us0d__0000012-001 Name
US12_00009 Name --> us0d__:000000012-/00000009 Name ---> us0d__0000012-009 Name
US36399_1 Name ---> us0d__:000000036399-/0001 Name -----> us0d__0036399-001 Name
Luuk
 
Posts: 811
Joined: Fri Feb 21, 2020 10:58 pm

Re: Assistance with complicated renaming task

Postby treehstn » Fri Aug 09, 2024 3:49 am

I never would have been able to come up with that solution! I'm trying to get it to work but nothing is happening. Here's a screen shot, maybe there's a setting that I need to fix? TY!

Image
treehstn
 
Posts: 8
Joined: Thu Aug 08, 2024 8:37 pm

Use different padding at different places

Postby Luuk » Fri Aug 09, 2024 3:14 pm

The screenshot doesnt show an ending ' Name' like in the example??
To rename files with-or-without an ending ' Name' ?, can just remove ' .+' from the "Match".
To only rename the files without any ending ' Name ?', should change ' .+' ---> $
Luuk
 
Posts: 811
Joined: Fri Feb 21, 2020 10:58 pm

Re: Assistance with complicated renaming task

Postby treehstn » Fri Aug 09, 2024 7:38 pm

Here's what I put in the fields. Is it supposed to also include something about "name"? TY!

Image
treehstn
 
Posts: 8
Joined: Thu Aug 08, 2024 8:37 pm

Use different padding at different places

Postby Luuk » Fri Aug 09, 2024 8:53 pm

Im no ideas if your now-names are always supposed to end with some ' Name' like your 1st-example??
Or if they should only sometimes-or-never end with some ' Name' like inside of the screenshot??
So whatever you might have, just edit the ' .+' accordingly.

The "Match" in your screenshot only rename files ending with some ' Name' like in your 1st-example.
Luuk
 
Posts: 811
Joined: Fri Feb 21, 2020 10:58 pm

Re: Assistance with complicated renaming task

Postby treehstn » Sat Aug 10, 2024 12:37 am

Here's more of an example of what I'm working with. The original file names are on the left. The desired file names are on the right. Just to give an idea of the scope of this task... I have 3000+ individual image files organized into 800+ folders. I need all of their names to look like the second column below.

PATENT # 4567
US04567-001 us0d0004567-001
US04567-002 us0d0004567-002
US04567-003 us0d0004567-003
US04567-004 us0d0004567-004
US04567-005 us0d0004567-005
US04567-006 us0d0004567-006
US04567-007 us0d0004567-007
US04567-008 us0d0004567-008
US04567-009 us0d0004567-009

PATENT # 123
Us00123_1 us0d0000123-001
Us00123_2 us0d0000123-002
Us00123_3 us0d0000123-003
Us00123_¬4 us0d0000123-004
Us00123_5 us0d0000123-005
treehstn
 
Posts: 8
Joined: Thu Aug 08, 2024 8:37 pm

Re: Assistance with complicated renaming task

Postby treehstn » Sat Aug 10, 2024 12:42 am

Sorry... that previous post didn't format very well. Trying it again with an image instead.

Image
treehstn
 
Posts: 8
Joined: Thu Aug 08, 2024 8:37 pm

Use different padding at different places

Postby Luuk » Sat Aug 10, 2024 6:21 am

For the latest examples (without an ending ' NameFormat'), could just change ' .+' ---> '$'.
But since now they might also use '-' before the ending digits, should change '_' ---> '[-_]'
And since 'US' might now need to be case-insensitive, I would put (?i) before the 'US'...

So after making these 3-changes, the v2 Match and Replace looks like...
^(?i)US(\d+)[-_](\d+$)(?X):0*(?=\d{7,})|/0*(?=\d{3,})/g
us0d:0000000$1-/000$2(?X)

us2-3 ----------> us0d0000002-003
us3_4 ----------> us0d0000003-004
Us123_4 -------> us0d0000123-004
Us00123_5 ----> us0d0000123-005
US04567-01 ---> us0d0004567-001
Luuk
 
Posts: 811
Joined: Fri Feb 21, 2020 10:58 pm

Re: Assistance with complicated renaming task

Postby treehstn » Sat Aug 10, 2024 8:22 pm

It worked!!! Thank you soooo much!
treehstn
 
Posts: 8
Joined: Thu Aug 08, 2024 8:37 pm

Re: Assistance with complicated renaming task

Postby treehstn » Sun Aug 18, 2024 9:13 pm

I had to finish up a different project and just got back to this one today. I've found a situation that the match and replace is not working. A bunch of the files are named something like USD2785. The match and replace won't work on these unless I remove the "D" manually from the file name. Is that something that can be added to the match so it will work with those names also?

Thank you!
treehstn
 
Posts: 8
Joined: Thu Aug 08, 2024 8:37 pm

Re: Assistance with complicated renaming task

Postby treehstn » Sun Aug 18, 2024 9:36 pm

Also... Is it possible with BRU to rename files and/or folders in subdirectories all at the same time without opening each one? In the following example can you change all the folder & file names using BRU?

Folder1
-----Subfolder1
---------File1
---------Filie2
---------File3
-----Subfolder2
---------File1
---------File2

Becomes:

Folder1
-----Subfolder001
---------File001
---------Filie002
---------File003
-----Subfolder002
---------File001
---------File002
treehstn
 
Posts: 8
Joined: Thu Aug 08, 2024 8:37 pm

Use different padding at different places

Postby Luuk » Mon Aug 19, 2024 9:10 pm

To also include names like USD2785, can put D? right-after 'US' inside of the "Match"...
us2-3 --------> us0d0000002-003
Usd1_4 ------> us0d0000001-004
Usa1_3 ------> (not renamed)
Luuk
 
Posts: 811
Joined: Fri Feb 21, 2020 10:58 pm

Pad 1st-number in names

Postby Luuk » Mon Aug 19, 2024 9:50 pm

To rename sub-folders and files, Filters(12) will need all 3-checkmarks for... Folders, Files, and SubFolders.
If all of your names are like the examples, could use Name(2) with 'PadNumbers' with 3 in the text-box.
Then after clicking your Folder1 in the folder-tree, it could rename like...
Folder1\SubFolder1\File1 ---> Folder1\SubFolder001\File001
Folder1\SubFolder1\File2 ---> Folder1\SubFolder001\File002
Folder1\SubFolder2\File1 ---> Folder1\SubFolder002\File001
Folder1\SubFolder2\File2 ---> Folder1\SubFolder002\File002

But if any name has more than 1-set of numbers, only the 1st-set gets padded, so like...
Folder1\Sub1Folder1\3File1 ---> Folder1\Sub001Folder1\003File1
Folder1\5-16-01-001\1of3 -----> Folder1\005-16-01-001\001of3


To only pad ending-numbers, its might be safer with another v2 regex "Match" an "Replace" like...
(\d+)$(?X):0*(?=\d{3,})
:000$1(?X)
Could also add this to your previous "Match" and "Replace", if wanting to conduct both at the same time??
You would just need to put (?X) before each of them.
Luuk
 
Posts: 811
Joined: Fri Feb 21, 2020 10:58 pm


Return to How-To