Create folder based on partial file name

Bulk Rename Utility How-To's

Create folder based on partial file name

Postby MnM007 » Fri Oct 28, 2022 10:14 am

Hi,

I have a few files with this name format:

22-10-2022-19-30-58-001.JPG
23-10-2022-21-29-46-002.JPG
23-11-2021-21-29-49-003.JPG

I want to create folders with names like this (based on the above example):

10-OCT-2022
11-NOV-2001

and then move the correct files into the correct folders (even if is a 2 step process)

Where 10 or 11 = the month (in numerical), then a 3 letter word for the month and finally the year.

All this taken from the file name at the bolded location - 22-10-2022-19-30-58-001.JPG

I have done the \ option in BRU (to be able to create folders) but my regex skills are ZERO so I am not capable of doing the above.

If anyone can help that will be great.

Many thanks.
MnM007
 
Posts: 8
Joined: Fri Oct 28, 2022 10:05 am

Move files into folders with month abbreviation

Postby Luuk » Fri Oct 28, 2022 11:56 am

If to settle the files like this?...
Folder\22-10-2022-19-30-58-001.jpg ---> Folder\10-OCT-2022\22-10-2022-19-30-58-001.jpg
Folder\23-10-2022-21-29-46-002.jpg ---> Folder\10-OCT-2022\23-10-2022-21-29-46-002.jpg
Folder\23-11-2021-21-29-49-003.jpg ---> Folder\11-NOV-2021\23-11-2021-21-29-49-003.jpg

Then RegEx(1) needs a checkmark inside for "v2", so then a "Match" and "Replace" something like...
^(\d\d-)((\d\d)(-20\d\d)(-\d\d){3}-\d{3})$(?X):01(?X):02(?X):03(?X):04(?X):05(?X):06(?X):07(?X):08(?X):09(?X):10(?X):11(?X)12
$3-:$3$4\\$1$2(?X)JAN(?X)FEB(?X)MAR(?X)APR(?X)MAY(?X)JUN(?X)JUL(?X)AUG(?X)SEP(?X)OCT(?X)NOV(?X)DEC
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm

Re: Create folder based on partial file name

Postby MnM007 » Sat Oct 29, 2022 5:23 am

Hi,

Thank you for your help.

I have done some testing and it looks like it works as it should. Really glad you could help me with the Regex :)

I have then moved to my next step - to automate the whole process.

So I have created a .bru file. In the BRU file I had all the settings done including the path to my files. The path to my files is a mapped network drive to the location on my NAS.
I saved the .bru file with the path in BRU to the right folder.

However when I load the .bru file I now get an error:

"Encountered and improper argument" and the path filed in BRU is empty.

It seems it cannot load the path from the .bru file

I opened the .bru file with vi and the path is there under:

[General]
Path="Z:\Incoming\PhotosAndVideos\Photos"

But is just not loading when the .bru file is opened.

If I browse manually to the network path in BBU (after I open the .bru file and click OK on the error) the .bru file works as it should.

If the path points to a local drive (not a mapped network drive) is loads just fine when I open the .bru file.

Not sure if this is something you can help me with (if I am doing something wrong here). Maybe it needs to be reported in another section of the forum? Or to support via email (in case I am not doing anything wrong.
MnM007
 
Posts: 8
Joined: Fri Oct 28, 2022 10:05 am

Network-paths in .bru-files wont conduct?

Postby Luuk » Sat Oct 29, 2022 11:37 am

Its unfortunate but Im not have any network-drives, so its impossible for me to troubleshoot.
I would first try changing it to something more like... Path="\\ComputerName\Folder\Path".
But since the mapped-drive wont conduct, the UNC-path will also probably not conduct?

If nothing is helping, I would definitely post this problem inside of the "Suggestions" forum.
Because if the .bru-files wont conduct network-paths, then .ini-files are probably the same?
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm

Re: Move files into folders with month abbreviation

Postby MnM007 » Thu Jan 19, 2023 11:02 pm

Luuk wrote:If to settle the files like this?...
Folder\22-10-2022-19-30-58-001.jpg ---> Folder\10-OCT-2022\22-10-2022-19-30-58-001.jpg
Folder\23-10-2022-21-29-46-002.jpg ---> Folder\10-OCT-2022\23-10-2022-21-29-46-002.jpg
Folder\23-11-2021-21-29-49-003.jpg ---> Folder\11-NOV-2021\23-11-2021-21-29-49-003.jpg

Then RegEx(1) needs a checkmark inside for "v2", so then a "Match" and "Replace" something like...
^(\d\d-)((\d\d)(-20\d\d)(-\d\d){3}-\d{3})$(?X):01(?X):02(?X):03(?X):04(?X):05(?X):06(?X):07(?X):08(?X):09(?X):10(?X):11(?X)12
$3-:$3$4\\$1$2(?X)JAN(?X)FEB(?X)MAR(?X)APR(?X)MAY(?X)JUN(?X)JUL(?X)AUG(?X)SEP(?X)OCT(?X)NOV(?X)DEC


Reviving this thread...

I am seeing errors with the above for any files that requires to go to a December folder. For example the below should work:

Folder\10-12-2018-19-30-58-001.jpg ---> Folder\12-DEC-2018\22-10-2022-19-30-58-001.jpg

But it doesn't. It gives an error in BRU (about a character hat Windows cannot accept as a folder name) and it wants to change the name of the file to:

DEC-:12-2018\10-12-2018-19-30-58-001.jpg

All other months work as it should. Only the DEC have the issue above.

Hopefully someone can help with the above issue.

Thanks
MnM007
 
Posts: 8
Joined: Fri Oct 28, 2022 10:05 am

Re: Create folder based on partial file name

Postby MnM007 » Fri Jan 20, 2023 9:49 am

Figured it out ...

one line was wrong it should be like this

^(\d\d-)((\d\d)(-20\d\d)(-\d\d){3}-\d{3})$(?X):01(?X):02(?X):03(?X):04(?X):05(?X):06(?X):07(?X):08(?X):09(?X):10(?X):11(?X):12(?X)

original was like this

^(\d\d-)((\d\d)(-20\d\d)(-\d\d){3}-\d{3})$(?X):01(?X):02(?X):03(?X):04(?X):05(?X):06(?X):07(?X):08(?X):09(?X):10(?X):11(?X)12
MnM007
 
Posts: 8
Joined: Fri Oct 28, 2022 10:05 am


Return to How-To


cron