folder name based on filename

Bulk Rename Utility How-To's

folder name based on filename

Postby johnsonb » Tue Apr 21, 2020 5:23 am

Would it be possible to create a folder based on a filename then copy the file into it?

thanks
johnsonb
 
Posts: 2
Joined: Tue Apr 21, 2020 5:20 am

Create Folder-name based on filename

Postby RegexNinja » Tue Apr 21, 2020 7:07 am

There is a 'folderize' option via: RenamingOptions / AdvancedOptions / AllowUsing'\'ToCreateFolders.
It allows creating folders based upon a filename's text, but it results a move command, not copy.
Its wise to combine that option with: RenamingOptions / PreventDuplicates=Checked to prevent overwrites.

There is also #13's Copy or MoveTo location for hard-coded FolderPaths (not based on filenames).
In that case, the FolderPaths wont be created, and must pre-exist before renaming.
The FolderPaths must also be FullPaths, not relative as allowed by the 'folderize' method.

Javascript could probably do what you need, but I dont feel comfortable providing details.
I'm using the free version, so there's no way I could test the functionality.
Let's hope someone with the paid version can shed some light onto it.
Cheers.
RegexNinja
 
Posts: 134
Joined: Fri Feb 21, 2020 5:26 pm

Re: folder name based on filename

Postby johnsonb » Tue Apr 21, 2020 11:48 am

Thanks for the help. Apparently, I do not have enough info put in to execute the program but I'll keep plugging along.

Thanks again
johnsonb
 
Posts: 2
Joined: Tue Apr 21, 2020 5:20 am

Re: folder name based on filename

Postby therube » Tue Apr 21, 2020 12:56 pm

How's this for a round about way...

ZIP up the file (7-zip, actually)
then unzip it (again, 7-zip)

Code: Select all
7-zip.exe  a  filename.7z  filename.ext
7-zip.exe  x  filename.7z  -o*


That will first zip up the filename.ext into filename.7z.
Then it will extract the file from filename.7z into a (sub)directory named filename.

So if you have a file named, test.jpg:
Code: Select all
7-zip.exe  a  test.7z  test.jpg
7-zip.exe  x  test.7z  -o*

You end up with, a (sub)directory named, /test/ which contains the file, test.jpg.

(The original file, test.jpg also remains.
You need not actually compress the file, simply storing it in the archive container (.7z) is fine & faster.
Depending on needs, you could automate this with a batch file, iterating through the list of files in a directory, creating the .7z's, then extracting the same into individually same named directories...
Iteration, would need to be done on a per file basis.
Extraction, directory creation, can be done en-mass, using an eXtract command like; 7-zip.exe x %* -o*)
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: folder name based on filename

Postby Admin » Wed Apr 22, 2020 2:42 am

Would it be possible to create a folder based on a filename then copy the file into it?


Yes, it is possible. You can use now '\' in the resulting file name, which automatically renames the file into a folder name + file name.

Can you provide some renaming examples? thanks
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: folder name based on filename

Postby RegexNinja » Wed Apr 22, 2020 2:58 am

Johnsonb:
If you'll post an example filename, with the desired FolderName [size-90](and NewName for the file, if desired)[/size].
I can provide assistance with the 1st-2 methods, just not with the 3rd-javascript method.
But I think both Admin/therube could help you out with that part.
Cheers!
RegexNinja
 
Posts: 134
Joined: Fri Feb 21, 2020 5:26 pm

Re: folder name based on filename

Postby trm2 » Mon Apr 27, 2020 4:05 am

Admin.

I am missing something and I literally wrote the book...

I am not understanding your reply abut the use of the backslash to create a directory using BRU other than the Copy/Move to Location.
It doesn't work with Append using it as a separator - Windows won't allow the renaming indicating the illegal character. I know how it is supposed to work
- I have a file manager that allows me to do just that - add the slash and it automatically creates the directory. But based on the folder name using BRU?

So please explain how to do this in BRU?
trm2
 
Posts: 156
Joined: Wed Jan 15, 2020 12:47 pm

Re: folder name based on filename

Postby Admin » Mon Apr 27, 2020 6:26 am

Hi, you can rename

filename into file\name (e.g. replace name with \name)

That will create folder file and rename filename into name.

You need option:
Advanced Options > Allow Using '\' in Renaming Criteria for Creation of New Folders (Advanced Option)
enabled

Use this option with caution. This option can create new folders during renaming and can not be undone. With this option selected, if the new resulting file name contains a \, then a new folder is created, instead of just considering the file name invalid. So for example, if you had a file called a.txt and your renaming-criteria caused the file name a.txt to become 20190801\a.txt, then a new folder 20190801\ is created and the file a.txt is moved in there. This is called 'folderize'. Using this option, you can reorganize files into folders based on their timestamps, for instance.
Before using this option it is recommended to backup your files.
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: folder name based on filename

Postby trm2 » Mon Apr 27, 2020 2:27 pm

Stupid Me!!

I thought it sounded familiar - page 171 - page 175 in the Manual!!! Ahhhk!

Dang memory - how embarrassing.


PS - I hope the page numbers are accurate - I have been working with different minor revisions since. If not, the
references would be near there.
trm2
 
Posts: 156
Joined: Wed Jan 15, 2020 12:47 pm

Re: folder name based on filename

Postby Admin » Tue Apr 28, 2020 2:54 am

Yes, it's there from page 171 8)
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm


Return to How-To