Keeping folder name but adding file name

Bulk Rename Utility How-To's

Keeping folder name but adding file name

Postby Peter Stevens » Fri Oct 29, 2021 7:14 am

Hi

First time poster. So here goes. I have a lot of folders that are all 8 digit numbers. I would like to keep the folder numbers. But I would like to add the file name inside the folder to it. Any help appreciated. Thanks.

Eg: Folder name is 24215896, and file name is Future Pop. I would like the folder to be renamed to Future Pop - 24215896. If need be I can add the - later on via a second pass.
Peter Stevens
 
Posts: 2
Joined: Fri Oct 29, 2021 7:07 am

Add filename into folder-path

Postby Luuk » Sun Oct 31, 2021 7:44 am

Bru wont look at filenames when conducting a foldername, but the javascript can edit a file's folder-path.
So with the commercial license, the javascript code would probably look something like...

if (/\\\d{8}\\$/.test(object('folder'))) {
newLocation=object('folder').replace(/.{9}$/,name.replace(/\.[^.]*$/,' - ')) + object('folder').replace(/.*(.{9})$/,'$1') }

Its not renaming anything, but when files are inside of 8-digit folders, it moves them into folder-paths like...
C:\Path\24215896\Future Pop.txt =====> C:\Path\Future Pop - 24215896\Future Pop.txt

The Filters(12) should only have checkmarks inside for "Files" and maybe also for "Subfolders".
It does also need a checkmark inside the menu "Renaming Options, File/Folder Extensions, Rename File Extensions".
This because Im not yet know any javascript variables to present only the name, without also having the .extension
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: Keeping folder name but adding file name

Postby Peter Stevens » Mon Nov 01, 2021 5:15 am

Thanks for the reply Luuk. I'm fairly new to BRU program so I will try and take on board what you said and will see how I go. Appreciate the feedback.
Peter Stevens
 
Posts: 2
Joined: Fri Oct 29, 2021 7:07 am

Re: Keeping folder name but adding file name

Postby Luuk » Mon Nov 01, 2021 12:30 pm

Another way is to first rename the files, and then use another run to 'folderize' them and undo the rename.
But you might have to be careful, to only select the files that are settled inside of the 8-digit folders.
If its a problem, you can drag the 8-digit folders into the file-list with a checkmark in Filters(12) Subfolders.

Rename1: C:\Path\24215896\Future Pop.txt =====> C:\Path\24215896\Future Pop - 24215896.txt

Filters(12) uses a checkmark in 'RegEx' and a Mask like (?<! - \d{8}\.[^.][^.][^.])(?<! - \d{8}\.[^.][^.][^.][^.])$
AppendFolderName(9) then uses Name==Suffix and Sep== - .
The Mask filters names ending like ' - 8digits' in case you already renamed some, or like renaming a few at a time.

================================================================================================

Rename2: C:\Path\24215896\Future Pop - 24215896.txt ===> C:\Path\Future Pop - 24215896\Future Pop.txt

First its important to make sure that the AppendFolderName(9) is turned off!
Then put a checkmark inside the menu "Renaming Options, Advanced Options, Allow using \ in Renaming Criteria".
Filters(12) uses a checkmark in 'RegEx' and a Mask like .* - \d{8}\.[^.]{3,4}$
Add(7) then uses a Prefix like ..\
RegEx(1) uses a Match like... ^((.+) - \d{8})$ and a Replace like... \1\\2

=================================================================================================

When everything is finished moving, then you could just delete all of the empty 8-digit folders.
BRU can find them by using the Filters(12) with checkmarks only inside of "Folders" and "Subfolders".
Then put a checkmark in 'RegEx' with a Mask like ^\d{8}$ then just click the blue arrows beside Mask.
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm


Return to How-To