mercredi 1 avril 2015

Could someone help me make a script that could structure files in folders (and subfolders) depending on their names?

I know there exist quite a lot of script out there to do such tasks, but I couldn't find any that can do what I am specifically searching for...


I am looking for a script that could read all files I have in a folder, separate all "_" and put them into subfolders.


The structure of the filenames look like this:



Clothes_Man_Citizen_Pants.png
Clothes_Man_Citizen_Top.png


The script would then create subfolders with this structure:



Clothes/Man/Citizen/Clothes_Man_Citizen_Pants.png
Clothes/Man/Citizen/Clothes_Man_Citizen_Top.png


I am asking this because I couldn't find any photoshop script to export nested groups in photoshop... So I'm exporting all the layers into a folder and would like to create the nested folder structure with a batch or something like that.


Thanks for your answers !


EDIT:


In pseudo-code it would look like this:



InitialName = Clothes_Man_Citizen_Pants.png;
TempName = Clothes_Man_Citizen_Pants.png;

While (There is an underscore in TempName) {
-> Read name until underscore
-> Create folder with name
-> Get into created folder
-> Remove part from TempName
-> Repeat
}


When there are no underscores anymore in TempName paste the file with InitialName in the last created folder.


Aucun commentaire:

Enregistrer un commentaire