Turn file names to folders

Bulk Rename Utility How-To's

Turn file names to folders

Postby RMcD » Wed Aug 04, 2021 9:29 am

I have a list of say, 1000 files. 600 of those were from folders and before I put them into a single folder.

Now I want to undo that flattening.

All of the files I want to put back are in the structure [original file name] - Relating ... [top folder] - Bla bla [subfolder 1] - blablabla [subfolder 2]

So I want to cut on the " - ", and for the first one I need to check it's "- Relating" and not just a random - in the file name, which I think is unlikely but I didn't check every file
https://i.imgur.com/CuipKFv.png

Is there a utility that could do this?
RMcD
 
Posts: 5
Joined: Wed Aug 04, 2021 9:19 am

Re: Turn file names to folders

Postby Luuk » Wed Aug 04, 2021 2:21 pm

For myself, Im prefer to move the files like this with using the Bulk Rename Utility, but I cannot advise without knowing the new full pathnames.
Which parts is the "Bla bla" or "blablabla" that should be removed?? Or should only the last word be used for each of the folder names??

Going by your description, and with the first example...
C:\CurrentFolder\[Original File name] - Relating..[Folder1] - Blabla [Folder2] - blablabla [Folder3]
C:\CurrentFolder\2013-12-02-1951-46 - Relating to Games - Recordings - With DnD Crew.mp4

Does this describe a new full pathname like?...
C:\CurrentFolder\Games\Recordings\Crew\2013-12-02-1951-46.mp4
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: Turn file names to folders

Postby RMcD » Mon Aug 09, 2021 12:33 pm

Luuk wrote:For myself, Im prefer to move the files like this with using the Bulk Rename Utility, but I cannot advise without knowing the new full pathnames.
Which parts is the "Bla bla" or "blablabla" that should be removed?? Or should only the last word be used for each of the folder names??

Going by your description, and with the first example...
C:\CurrentFolder\[Original File name] - Relating..[Folder1] - Blabla [Folder2] - blablabla [Folder3]
C:\CurrentFolder\2013-12-02-1951-46 - Relating to Games - Recordings - With DnD Crew.mp4

Does this describe a new full pathname like?...
C:\CurrentFolder\Games\Recordings\Crew\2013-12-02-1951-46.mp4


Your example is almost correct

C:\CurrentFolder\Relating to Games\Recordings\With DnD Crew\2013-12-02-1951-46.mp4[/quote]

Spaces next to "-" should be trimmed but not spaces within the text. Well, it's not the end of the world if the folder names are wrong, as long as they're all wrong in the same way. So that the files get sorted into the right folders and I just have to rename the folders after I finish with the whole folder.
RMcD
 
Posts: 5
Joined: Wed Aug 04, 2021 9:19 am

Re: Turn file names to folders

Postby Luuk » Mon Aug 09, 2021 1:55 pm

First to put a checkmark inside for the menu "Renaming Options, Advanced Options, Allow using '\' in Renaming Criteria".
Then inside of the Regex(1), to put a checkmark in "v2", with a 'Match' and 'Replace' like...
^((?:(?! - ).)+) - (Relating(?:(?! - ).)+) - ((?:(?! - ).)+) - ((?:(?! - ).)+)$
$2\\$3\\$4\\$1

This to only conduct names if... "Relating" follows the very first " - " and the filename must have exactly 3-occurrences of " - ".
Because otherwise its getting confused how to decide if an extra " - " might be part of the filename, or just another foldername?

So this how it like to rename...
C:\CurrentFolder\2013-12-02-1951-46 - Relating to Games - Recordings - With DnD Crew.mp4 ===>
C:\CurrentFolder\Relating to Games\Recordings\With DnD Crew\2013-12-02-1951-46.mp4
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: Turn file names to folders

Postby RMcD » Fri Aug 13, 2021 11:34 pm

That has worked perfectly, you're a genius mate.

There are around 200 files that have 2 "-" or 4 "-".

Now that the files are so greatly reduced I was able to skim them and I'm reasonably confident that there are no " - " used in any names. There are some #-# but they all have no spaces, like in numbers. Next time I really shouldn't use "-" and use some more obscure character, or avoid the flattening in the first place, but I digress.

So if I'm understanding what you wrote (and I absolutely don't) is it just a matter of removing the $4 and the black - brackets for 2 and adding another one for 4 ($5)?

So

^((?:(?! - ).)+) - (Relating(?:(?! - ).)+) - ((?:(?! - ).)+)$
$2\\$3\\$1


^((?:(?! - ).)+) - (Relating(?:(?! - ).)+) - ((?:(?! - ).)+) - ((?:(?! - ).)+) - ((?:(?! - ).)+)$
$2\\$3\\$4\\$5\\$1
RMcD
 
Posts: 5
Joined: Wed Aug 04, 2021 9:19 am

Re: Turn file names to folders

Postby Luuk » Sat Aug 14, 2021 2:32 am

Both edits look perfect! The first to conduct exactly 2-occurrences of ' - ' and the other conducts 4.
And both of them, still do need that "Relating" must follow after the very first-occurrence of ' - '.
To conduct both at the same time, can use (?X) to separate different Match and Replaces like...

^((?:(?! - ).)+) - (Relating(?:(?! - ).)+) - ((?:(?! - ).)+)$(?X)^((?:(?! - ).)+) - (Relating(?:(?! - ).)+) - ((?:(?! - ).)+) - ((?:(?! - ).)+) - ((?:(?! - ).)+)$
$2\\$3\\$1(?X)$2\\$3\\$4\\$5\\$1
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm


Return to How-To