Page 1 of 1

Keeping folder name but adding file name

PostPosted: Fri Oct 29, 2021 7:14 am
by Peter Stevens
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.

Add filename into folder-path

PostPosted: Sun Oct 31, 2021 7:44 am
by Luuk
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

Re: Keeping folder name but adding file name

PostPosted: Mon Nov 01, 2021 5:15 am
by Peter Stevens
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.

Re: Keeping folder name but adding file name

PostPosted: Mon Nov 01, 2021 12:30 pm
by Luuk
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.