Sort into subfolders based on filename, then rename

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Hey all, I have been reading the docs and searched previous topics but can't quite figure this out.

Here's what I want to do:
1. Scan the "assets" folder and find any pngs inside a sub-folder called "images"
2. Move those png files into the parent "assets" directory
3. Delete the "images" folder when it is empty
2. Sort the png images into subfolders based on the filename, where "-" represents a place to create a subfolder
3. Rename the moved png files to remove the subfolder sequence and just leave the characters after the last "-"

Example would be:
assets > images > floor-normal-a_depth0_light0.png --> assets > floor > normal > a_depth0_light0.png

So, the file would be placed into a subfolder structure based on the "-" separator.
Then it would be renamed to "a_depth0_light0.png"

Here are some more example image names, and my desired results, to clarify:
As you can see, each segment of the image filename will vary, as will the amount of subfolders necessary.

floor-normal-a_depth0_light0.png --> floor > normal > a_depth0_light0.png
structure-1.png --> structure > 1.png
walls-submerged-a_depth2_light2.png --> walls > submerged > a_depth2_light2.png
entitySmall-submerged-6.png --> entitySmall > submerged > 6.png

Thank you, I'll be very grateful if anyone can help.
zenjl
 
Posts: 1
Joined: Sat May 06, 2023 10:09 pm

Not sure if this is entirely possible. You can create a custom attribute to match the first "component" in the filename, rename the file with everything outside of that, and sort into subfolder using that custom attribute. The problem is whether it will repeat properly. Look up match patterns on how to do this.

Note that you will also need to use a subfolder rule (see manual as there's a whole chapter on this).

Report back if you run into any problems.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support