Page 1 of 1

folder name based on filename

PostPosted: Tue Apr 21, 2020 5:23 am
by johnsonb
Would it be possible to create a folder based on a filename then copy the file into it?

thanks

Create Folder-name based on filename

PostPosted: Tue Apr 21, 2020 7:07 am
by RegexNinja
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.

Re: folder name based on filename

PostPosted: Tue Apr 21, 2020 11:48 am
by johnsonb
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

Re: folder name based on filename

PostPosted: Tue Apr 21, 2020 12:56 pm
by therube
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*)

Re: folder name based on filename

PostPosted: Wed Apr 22, 2020 2:42 am
by Admin
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

Re: folder name based on filename

PostPosted: Wed Apr 22, 2020 2:58 am
by RegexNinja
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!

Re: folder name based on filename

PostPosted: Mon Apr 27, 2020 4:05 am
by trm2
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?

Re: folder name based on filename

PostPosted: Mon Apr 27, 2020 6:26 am
by Admin
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.

Re: folder name based on filename

PostPosted: Mon Apr 27, 2020 2:27 pm
by trm2
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.

Re: folder name based on filename

PostPosted: Tue Apr 28, 2020 2:54 am
by Admin
Yes, it's there from page 171 8)