Copy link to clipboard
Copied
Not super familar with scripting, how would one create a script that you could point towards a folder, and it would itterate through each subfolder, turning it's contents into a gif with the name of the subfolder? The images themselves in each subfolder are ordered, so there would be no major concern of it getting frames wrong.
Thanks!
@111aaa11 – Here is a new version to automatically process all sub-folders under the selected top-level folder.
EDIT: Original code updated to 1.1 to correct an oversight where %20 characters were output instead of word spaces in saved filenames.
/*
Create GIF89a files from PNG Files in All Sub-folders of Selected Folder.jsx
v1.1 - 24th February 2024, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/script-to-generate-gif-from-folder-of-images/td-p/14438104
*/
#
...
Copy link to clipboard
Copied
Please provide a screenshot of the before and after directory structure and filenames. It's unclear if the sub-folder name would be a prefix or suffix.
Copy link to clipboard
Copied
The main folder and subfolders appear like so, https://imgur.com/a/906kxeu
The result would just be a folder containing gifs consprised of the frames found within each subfolder. Framerate, etc doesn't matter as they will be adjusted in the program I will be using these gifs for.
Copy link to clipboard
Copied
You can attach images to your post using the web browser reply (not via email). Just in case the link breaks in the future:
If I understand your request correctly, a sub-directory name might be:
spr_player_mask
And it may contain multiple source PNG files, with similar names to:
0.png
1.png
2.png
And the final result should then be multiple static GIF files with an underscore _ separator using the sub-directory, separator and original image name? Such as:
spr_player_mask_0.png
spr_player_mask_1.png
spr_player_mask_2.png
Or do you wish to create an animated GIF in a single image file from each PNG frame?
What GIF conversion options are required for colour conversion from RGB to Indexed Color mode?
Copy link to clipboard
Copied
EDIT: I just re-read your post, you do require a sinlge animated GIF output.
So the second screenshot was of each frame, so you just with to combine these into a frame animation and use the parent folder as the name of the animated GIF.
Yes?
Copy link to clipboard
Copied
Correct, and have that action be done for all the subfolders
Copy link to clipboard
Copied
Correct, and have that action be done for all the subfolders
By @111aaa11
Hmmm... I'm pretty sure that I can automate this for one sub-folder at a time (manually selecting each sub-folder)... EDIT: I have code to recurse into all sub-folders, but it's having issues working on Windows when it runs fine on a Mac.
It's probably best to initially script this for manual use, one folder at a time. The script can be "upgraded" to process each sub-folder individually once I have the recursive code working.
P.S. Where should the GIF be saved, into the sub-folder or outside of the sub-folder in the root/top-level folder?
Copy link to clipboard
Copied
Root folder would be the easiest
Copy link to clipboard
Copied
I will use the following GIF conversion options unless you have different requirements:
Please let me know if you need any changes, such as using a smaller colour palette than 256, such as 128... Or if you don't wish to convert colours to sRGB, or a lesser dither value than 100% etc.
Providing a screenshot of your Save for Web would be best.
Is ###_0.png the first frame, with ###_9.png as the last frame of the animation?
Will there be more than 10 frames?
P.S. If you could provide a link to at least two folders of source images that would be great, you can private message me the link if you don't wish to put it in the public forum.
Copy link to clipboard
Copied
Examples sent, there may be some cases where there will be over ten frames, but those can be handled manually if need be
Copy link to clipboard
Copied
Did find a script on the forums, may be easier to modify that and go from there.
Also, did note that there are a couple more 10+ frame animations than I expected, if its not a huge hassale to get those working, it would be greatly appreciated.
Copy link to clipboard
Copied
Thanks, I already have the script written to stack and animate one manually selected sub-folder at a time. EDIT: I had forgotten about participating in that old topic... Looks like I have just re-invented the wheel!
P.S I haven't seen a PM with two different full sample sets to test.
Just waiting on your confirmation of the desired save for web gif settings. Please provide a screenshot.
My concern with numbering starting at zero and larger in quantity than 10 files is the layer stacking/sorting order. The order can get messed up.
It's best to use zero padding such as 0001_ and 0002_ etc as as prefix or suffix rather than a single digit suffix. Can you change how the filenames are generated for the frames? Or you can use Adobe Bridge or other software to batch rename the files.
Here's a visual of the problem with single digit numbering with values larger than 10, in this example 12 numbers with filenames from 0-11:
When a script processes the filenames, the order is incorrect, here is the GIF animation:
1, 2, 11, 12, 3, 4 etc.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thank you, your GIF settings are essentially the same as mine. Please reply to my post regarding the issue with your filenames and the sorting order.
Copy link to clipboard
Copied
Apologies, but yes I do believe that bulk renaming would be possible with regex or bridge, would need to learn how but yes.
Copy link to clipboard
Copied
I can help with Bridge Batch Rename and RegEx. It all comes down to how consistent the naming pattern is.
Copy link to clipboard
Copied
Figured it out, but yes all the folders have the foldername_number format.
Copy link to clipboard
Copied
Figured it out, but yes all the folders have the foldername_number format.
By @111aaa11
Great!
Sorry to ask... But is the _number format zero padded? Such as:
001_
002_
...
012_
etc.
Copy link to clipboard
Copied
correct
Copy link to clipboard
Copied
If you can put all images in a single folder with ordered names, you can use an Action. The first item in the Action would be the menu item to Load Files Into Stack (under Files > Scripts). Just point to the image folder and the rest can be automated with the Action. No need for a new script.
Copy link to clipboard
Copied
@mangurian1 wrote:
If you can put all images in a single folder with ordered names, you can use an Action. The first item in the Action would be the menu item to Load Files Into Stack (under Files > Scripts). Just point to the image folder and the rest can be automated with the Action. No need for a new script.
Can you explain how the following requirement would be achieved?
itterate through each subfolder, turning it's contents into a gif with the name of the subfolder
Copy link to clipboard
Copied
Read my first sentence carefully.
Copy link to clipboard
Copied
Read my first sentence carefully.
By @mangurian1
I did, which is why I asked. So it appears that the requirement of the OP can't be achieved with your suggestion.
Copy link to clipboard
Copied
right
Copy link to clipboard
Copied
Thank you for confirming, I thought that I was missing something!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now