Add Subdirectory When Renaming Folders

Advanced Renamer forum
#1 : 28/03-24 14:33
Jim Zons
Posts: 1
I am working with a photo machine that takes pictures and then saves those images into a variety of folders. I have a process setup where Advanced File Renamer renames the folders with the images to the first six numbers of the folder name (to match a SKU) but I would also like the ability to create a new subdirectory/folder at the same time, with the name 360. So, this folder:

402150-Spring Step- Womens- Lavona- white

Using this expression: <Substr:1:6>

Is renamed:

402150

But ... is there a way to not only rename that folder, but create a new subdirectory/folder called 360, so it would have the following directory structure:

402150/360

If not, please consider this a feature request ... THANK YOU!
#2 : 28/03-24 19:37
Delta Foxtrot
Posts: 323
Reply to #1:

Hi Jim,

That's an interesting problem. I don't think there's any way to do it without a lot of manipulation.
But if you've got a lot of folders to process, this would assuredly save you time and typing–although there are probably better ways to do it.. I have a program called Text2Folders that will create a folder structure from a text document, that would do it. After you renamed your folders you'd just run a "dir /b > newfolders.txt", or whatever cmd on the directory of your folders and then use a text editor to append "\360" on the end of each folder name. I'm sure that program can be found out there in interwebs.

There is one way I thought of that you could use to do it all in ARen, but it's pretty kludgy and takes several steps.

Using Rename mode, rename the folders.
Change to Move mode and move the folders to [someFolder]\<Name>\360
Load the files in all the folders and tell ARen to move them to ..\.. which should put them in the directory you want, that you created in the previous step.
Drag and drop into ARen the new folders you've created (the ones with \360 in them, they'll be all grouped together in Explorer and so easy to drag. Sort on Foldername column and all the folders you want to eliminate will be sorted together. Unmark or remove everything else and then move them all to the Recycle Bin... I said you could do it all in ARen! :)

Well, at least you have options. (:

Cheers,
DF

PS- Watch, someone will come along and prove me wrong. Maybe.
#3 : 28/03-24 21:02
Styb
Posts: 117
Hello, you can use a batch file if the new folders from your camera are always created in the same main folder, e.g. D:\MyFolder

1- Save the new naming method as a .aren file, e.g. D:\MyFolder\subs1-6.aren
2- Create a bat file via ARen menu Tools -> Command line -> https://i.postimg.cc/R0V43RYf/Img36.png
3- Add the following strings to the bat file
set "main_directory=D:\MyFolder"
for /d %%D in ("%main_directory%\*") do (md "%%D\360")

The final bat file will look like this
"C:\Program Files\Advanced Renamer\arenc.exe" -e D:\MyFolder\subs1-6.aren -t folders -p D:\MyFolder -m rename
set "main_directory=D:\MyFolder"
for /d %%D in ("%main_directory%\*") do (md "%%D\360")

Now, whenever you import new folders from your camera into the MyFolder dir, you can run the batch file to rename and create the subdirs called 360.



edited: 28/03-24 21:10
#4 : 29/03-24 01:41
Delta Foxtrot
Posts: 323
Reply to #3:

Good one, Styb!

I wonder if you could do the whole thing (I mean, shorten the filenames too) in batch. I know there's the :~ (substring) instruction, but I don't think you can use it in a for loop. So I think you could do it in a subroutine, but I'm not smart enough to figure all that out.

Anyway, just a thought. Good job, though. I never even knew about that Tools/Command Line trick! :)

Best,
DF

edited: 29/03-24 01:42
#5 : 29/03-24 09:54
Styb
Posts: 117
Reply to #4:
Hi DF,
my programming skills are very basic. Fortunately, this is not a forum to discuss programming.
:D