Adobe Script Tutorial 5 Photoshop Process Folder and Save JPEGs
HTML-код
- Опубликовано: 4 янв 2025
- Part Five of the series we switch to Photoshop. Using the tutorial code developed so far, with a few adjustments it becomes a Photoshop script to open files in a folder and save all as JPEG to another folder.
Get example code: www.marspremed...
Visual Studio (VS) Code: code.visualstu...
ExtendScript Debugger: marketplace.vi...
How to install Illustrator scripts macOS: • Illustrator Scripts Ho...
How to install Illustrator scripts Windows: • Illustrator Scripts Ho...
How to install InDesign scripts macOS: • InDesign Scripts How t...
How to install InDesign scripts Windows: • InDesign Scripts How t...
How to install Photoshop scripts macOS: • Photoshop Scripts How ...
How to install Photoshop scripts Windows: • Photoshop Scripts How ...
More about installing scripts both macOS and Windows: www.marspremed...
Other useful scripts for Adobe Creative Cloud applications: www.marspremed...
EXTENDSCRIPT RESOURCES
InDesign ExtendScript API
www.indesignjs....
Photoshop ExtendScript API
www.indesignjs...
Illustrator Scripting Guide
ai-scripting.d...
JavaScript Tools Guide
extendscript.d...
ScriptUI for dummies
creativepro.co...
(PDF) Adobe Creative Cloud JavaScript Tools Guide
download.macro...
(PDF) Illustrator CC Scripting Guide
www.adobe.com/...
(PDF) Illustrator CC Scripting Reference JavaScript
wwwimages.adobe...
(PDF) Illustrator Scripting Guide (2021)
readthedocs.or...
(PDF) Photoshop CC Scripting Guide (2013)
wwwimages2.ado...
(PDF) Photoshop Scripting Reference (2020)
www.adobe.com/...
JPEG file icon used in thumbnail created by iconixar - Flaticon - www.flaticon.c...
I have been going through your tutorials the last few days. Very helpful. Thank you for making these.
You are welcome. Thanks for the feedback.
Great job William, many thanks from Marco
Thank u so much
Glad it helps. Thanks for watching.
awesome works @William The way you explain is very clear keep doing more videos & keep Rocking 👏👍
Great, I'm glad you like it. I have #6 and #7 already finished, will be out in the coming weeks. More to come. Any subjects you would like covered let me know. All suggestions are welcome. Thank you for your support.
@@wc7 Waiting for your updates 6 & 7 😊. Yes I have a subject..Is it possible to filter the images by their names using scripts for example I have given 500 images to my client and they have filtered 250 out of them by sending me the file names in document/ spreadsheet . How can I filter them and select the images ? is possible in scripts?
@@Ranjithkumar-ph5rp We can solve that without a script. Just takes Excel and a batch file. Are you on Windows? I'm making a quick video now that shows how to do it.
@@Ranjithkumar-ph5rp Just posted a video showing how to do it on Windows. ruclips.net/video/SPTlzu3QIjY/видео.html
@@wc7 yes I use windows...sure i'm Waitingggg ☺
Thanks Nice sr
You're welcome. And I got the other script you sent. VERY enlightening. It uses a Photoshop feature I wasn't aware of. I will be in touch with a script you should like very much. And later, another episode in this series of how to write it. I am very grateful for your feedback. It's been wonderful.
@@wc7 I'm glad you understood me, listened to me and gave me the script thanks sr
I don't create scripts but I have a lot of ideas. I modify the script according to my need and finish my work
Thanks sir :) so useful :D
Amazing tutorials. How do I save to source folder without selecting each ? I'm working on lots of subfolders and it is tedious to keep selectin each subfolder input and output.
The tutorials I start with blank folder paths but these don't have have to be blank. The folder path can be hard-coded when the interface control is defined. For this tutorial (#5) for example, edit the line that defines the static text of the folder path:
txtFolderInput = g.add("statictext", undefined, "/Path/To/The/Desired/Folder/Here", {
truncate: "middle"
});
The third argument is the text to display. Make it a valid path and it's already set, no need to click the folder button unless you want something else. Same applies to the output folder.
@@wc7 Thank you so much.
Nice sir😊👌👌👌
Thank you
@@wc7 well come
thanks sir 😍 but I want to add a count of the number of exported image files and image files of the input folder, what code do I need to add? For example: A / B is displayed with the progress table (eg A is the number of files that have been output, B is the number of files in the input folder)
The tutorial includes a progress bar. The number of files in the selected folder can be obtained by the array returned by the getFIles method. In the tutorial the result is assigned to the variable 'files'. So files.length is the length of the array, in other words, how many members in the array, how many files. If you want to track how many files are processed, create a variable 'count'. Start at zero, count = 0. Each time a file is processed, increment. count++; Then at the end look at the value of count. It's the number of files processed.
@@wc7 Can you make a detailed video? because I'm newbie 😁 Thank sir
Can I have a sample please?
A sample of what? The code? Link is in the description. Or do you mean something else? Please clarify. Thanks.
Hi William, do you have any scripts that would put a file name on an image. I’m currently using one by JJ Mack, for photoshop. The problem I’m having is trying to change the font, currently it’s coded like this “ArialMT”, this displays the Arial font to the image, I would like to change this to display Source Code Variable - Regular. Would you know how this should be written in the script or how I can find correct way to type this?
The trick is you need to use the font's PostScript name. Open the script in a text editor and search for "ArialMT". You should find the line that sets the font. Most likely something like textItem.font = "ArialMT"; I don't have the font you're referring to but I do have "Source Code Pro" on my Windows workstation. That font, for example, the PostScript name is "SourceCodePro-Regular". Many times you can guess the PS font name but not always. To find font names I have a little script that helps. I set the "find" var to "Source Code" in the code. Anyone can edit the script to change what to search for. The script alerts each font that matches the find var (matches meaning it has the text in its name). Download here: www.marspremedia.com/download?asset=photoshop-get-font-postscript-name.zip
@@wc7 Amazing it worked, thank you so much. 🤓
@@hamishhamilton6923 Great. Your comment also gave me a new idea. I just put together a script that reads all the fonts and writes out a CSV file with the names and PostScript names for all. And I made it also work in Illustrator and InDesign. I'll make a video explaining it with a download link. Coming soon. Thanks for the feedback. Comments like yours always give me new ideas.
@@wc7 That sounds amazing, great idea!. I'm sure that will be very useful 🤓
An afterthought... you asked "put a file name on an image." Yes I have a script for that. Look at this and tell me if that's what you mean: ruclips.net/video/eluuL8PX6I8/видео.html
And is there any way to link C or C++ coding to photoshop?
developer.adobe.com/photoshop/uxp/ps_reference/media/advanced/cpp-pluginsdk/
Thank U but how to select subfolder please ? I put the subfolder with images in the folder but the script write 'its empty" , Thx U :).
There is not a simple answer to that. I will make a video explaining how to do it, which requires a function that calls itself (recursion) to gather the contents of the folder and also the contents of every folder inside the folder and inside every folder inside the folder. Down the rabbit hole, shall we say.
For now refer to another of my scripts:
www.marspremedia.com/software/photoshop/process-folder
Download this script and open in your editor. This script has a function named "getFiles()". Copy that function to your script and call it instead of "Folder.getFiles()". Pass the folder parameter and "true" for the subfolder parameter and it gets files in subfolders also.
@@wc7 Thank U so much ♥ , its possible to add the file in photoshop but stored by name and not by folder like 1a in folder A and 1b in folder B (as 1a,1b etc) Please ? :)
@@Ozveidt Yes it's possible, but difficult to fully explain in a comment, but I'll try to set you in the right direction. When you "get files" using either method, the result is an array of file objects. Each has various properties. Here is a link to a reference of those properties:
www.indesignjs.de/extendscriptAPI/photoshop-latest/#File.html
The property you want is "path". This is where the file is stored -- the folder -- without the file name. Paths are separated by slashes (/). So the last segment, after the last slash, is the subfolder the file is in. You want only that, not the entire path, which is from the top level of the computer file system. Use a regular expression pull out only the last segment.
var subfolderName = file.path.replace(/\/([^\/]+)$/, "$1");
Then look at the tutorial 5 code, function processFile, line 122
fileJpg = new File(txtFolderOutput.text + "/" + file.name.replace(/\.[^\.]*$/, "") + ".jpg");
Instead of file.name.replace... etc. make your own file name based on the subfolder name, for example...
var fileName = "1" + subfolderName;
And replace that part of line 122 to look like this instead:
fileJpg = new File(txtFolderOutput.text + "/" + fileName + ".jpg");
That's roughly how to do it and should light the way, I hope.
@@wc7 Ok, i see thank U , i will check .
U'r a good personne ♥
@@Ozveidt Thanks. I've added the topic to my list of future tutorials. Thank you for the suggestion. I'll combine how to deal with subfolders with how to use custom names when saving images. Should be another good tutorial video for the series.
how to find duplicate layers in photoshop and delete it.?
But what is a duplicate layer? Same name? That wouldn't be difficult, but same name doesn't guarantee same content. Completely different layers could have same name. Maybe that's all you mean. For same content, I imagine use blending mode difference one layer over another and look for any results. If none, I'd think they are the same content. Is that what you mean?
@@wc7 thank you for your reply.By mistake i sometimes copy layer names twice ,so to delete it ,how can i use the script?
@@joviion2040 I would be worried about using a script for this. How do we make sure not to delete wanted layers if only deleting layers of same name? It could be a dangerous script.
Can I have a sample please?
See response to duplicate question.