Copy link to clipboard
Copied
Is there any way I can set this sort of thing up in an action?
I curently use a simple generic action to flatten, save and close the file I am working on, an it simply overwrites the file in is current location. All good.
But not I want a similar Action to be able to save the same file (after resizing) file in a different folder, which will always be up one level, and I need trhis to work no matter what file for whatever client I am working on.
For instance, part of my base client folder structure is as follows:
c:\client name\Finished Files
c:\client name\Cropped Files
where "client name" is the name of the client
So when I have a file open in Finished Files, and I hit my curent action, it simple saves overt eh original file in the same place. But I would like to be able to save a rezed version in the other directory, which will always be there for all my client directory structures.
If I create an action to save in the Cropped Files directory, then the path the that clients Cropped Files will always be used. How can I make the action to work relative to the client directory structure?
Thank in advance
Try recording the execution of this script as the JPEG Save As (Copy) step in your action to save to the “Cropped” folder in the active client folder:
/*
JPEG Save As a Copy to Named Directory using Relative Path.jsx
Stephen Marsh
v1.0 - 7th December 2024
https://community.adobe.com/t5/photoshop-ecosystem-discussions/action-to-use-relative-path-of-file/td-p/15023267
*/
#target photoshop;
if (app.documents.length) {
// Check and cancel the script if the bit depth is 32
...
Copy link to clipboard
Copied
Actions always record absolute paths from the local machine recording the action.
You either override the recorded save when using Batch/Droplets – or you use a script instead, which can work with paths without the limitations of actions.
Copy link to clipboard
Copied
Ok, great thanks.
I guessed it might need scripting, which can presumably be invoked by an action?
How do I go about creating scripts?
Copy link to clipboard
Copied
Ok, great thanks.
I guessed it might need scripting, which can presumably be invoked by an action?
How do I go about creating scripts?
By @Liberty & Lace
That's a bit of a loaded question.
Legacy scripting (what you mostly see on these forums) uses ExtendScript, however, there are less capable AppleScript and VB Script options.
Adobe have shifted to UXP scripting for the future, however, it isn't as accessible as I would like.
Can you post a screenshot of the file format options that you would use when saving, or a screenshot of an action step showing the file format options?
Copy link to clipboard
Copied
The filel will have already been cropped and resized, im just looking to be able to hit a button and fire an action thats similar to this one, except I need the file to not save over the existing file, but be placed in aniother directory, which will always be in the same place relative to the client and called the same.
This is the one I currently use to just flatten, save and close the current file
Copy link to clipboard
Copied
So I need the save to save to d:\homesight studios\clients\<client name>\Cropped\
where the client name is in the path of the currently editing file path
Copy link to clipboard
Copied
So I need the save to save to d:\homesight studios\clients\<client name>\Cropped\
where the client name is in the path of the currently editing file path
By @Liberty & Lace
So if you are currently working on a file with a backing path of:
d:\homesight studios\clients\client name A\Hi Res Files\
You want the action to perform whatever steps and then to save as JPEG level 12 in:
d:\homesight studios\clients\client name A\Cropped\
And there will always be directories named "Hi Res Files" and "Cropped" in every client folder.
Copy link to clipboard
Copied
yes, exactly that!
Copy link to clipboard
Copied
and the file is open in the Hi Res Files directory, and the existing action simply saves it in place, which works becvause I dont have to specify a path, it just uses the current location
Copy link to clipboard
Copied
Strangley, the client path for the last time I used it, seems to be stored in the action, but when I move onto the next client, it gets replaced. Probably because when I saved the action, i just hit save, not save as, which woul have cemented in the path ? I dont understand that, but Ive been happy it works
Copy link to clipboard
Copied
-
Copy link to clipboard
Copied
Try recording the execution of this script as the JPEG Save As (Copy) step in your action to save to the “Cropped” folder in the active client folder:
/*
JPEG Save As a Copy to Named Directory using Relative Path.jsx
Stephen Marsh
v1.0 - 7th December 2024
https://community.adobe.com/t5/photoshop-ecosystem-discussions/action-to-use-relative-path-of-file/td-p/15023267
*/
#target photoshop;
if (app.documents.length) {
// Check and cancel the script if the bit depth is 32 bpc
if (app.activeDocument.bitsPerChannel == BitsPerChannelType.THIRTYTWO) {
throw alert("Script cancelled!\rThe image mode is 32 bpc, tone mapping to 8 or 16 bpc is required before continuing.");
}
// Doc name and save path variables
var theDocName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var relParentPath = app.activeDocument.path.parent.fsName;
var targetDir = "Cropped"; // Change as required for other relative paths
var relTargetDir = new Folder(relParentPath + "/" + targetDir);
var theFilePath = new File(relTargetDir + "/" + theDocName + ".jpg");
// Check for and create the target directory if it doesn't exist
if (!relTargetDir.exists) {
relTargetDir.create();
}
// JPEG options
var jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = 12;
// Overwrite check (comment out or remove this block for silent use in an action)
if (theFilePath.exists) {
// true = 'No' as default active button
if (!confirm("File exists, overwrite: Yes or No?", true))
// throw alert("Script cancelled!");
throw null;
}
// Save As a Copy (use false for Save As)
app.activeDocument.saveAs(theFilePath, jpgSaveOptions, true, Extension.LOWERCASE);
} else {
alert("You must have a document open to use this script!");
}
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
Copy link to clipboard
Copied
WOW! Thank you so much for doing that.
I certainly will give it a try, once I work out how 🙂
Copy link to clipboard
Copied
WOW! Thank you so much for doing that.
I certainly will give it a try, once I work out how 🙂
By @Liberty & Lace
You're welcome. Full instructions were posted in the link under the code.
Copy link to clipboard
Copied
Yay, it works an absolute treat!!!!
Thanks so much !!! 🙂
Copy link to clipboard
Copied
Spoke too soon lol
I created two versions of the script and installed them, the only difference being the target directory.
Now, when I run either script, they both seem to run, and create the same file in both directories, only correctly renamed, (I added a suffix for the cropp size).
Even if I run just one of the scripts by hand, it creates both fioles in both directories lol 😛
Any idea whats going on here?
Copy link to clipboard
Copied
Hard to comment without seeing the </> code.
Copy link to clipboard
Copied
Literally running what you sent as a script in PS, but with the direwctory changed thus and also one for "Facebook Reel Size"
/*
JPEG Save As a Copy to Named Directory using Relative Path.jsx
Stephen Marsh
v1.0 - 7th December 2024
https://community.adobe.com/t5/photoshop-ecosystem-discussions/action-to-use-relative-path-of-file/t...
*/
#target photoshop;
if (app.documents.length) {
// Check and cancel the script if the bit depth is 32 bpc
if (app.activeDocument.bitsPerChannel == BitsPerChannelType.THIRTYTWO) {
throw alert("Script cancelled!\rThe image mode is 32 bpc, tone mapping to 8 or 16 bpc is required before continuing.");
}
// Doc name and save path variables
var theDocName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var relParentPath = app.activeDocument.path.parent.fsName;
var targetDir = "Instagram Squares"; // Change as required for other relative paths
var relTargetDir = new Folder(relParentPath + "/" + targetDir);
var theFilePath = new File(relTargetDir + "/" + theDocName + "_InstaSquare.jpg");
// Check for and create the target directory if it doesn't exist
if (!relTargetDir.exists) {
relTargetDir.create();
}
// JPEG options
var jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = 12;
// Overwrite check (comment out or remove this block for silent use in an action)
//if (theFilePath.exists) {
// // true = 'No' as default active button
// if (!confirm("File exists, overwrite: Yes or No?", true))
// // throw alert("Script cancelled!");
// throw null;
//}
// Save As a Copy (use false for Save As)
app.activeDocument.saveAs(theFilePath, jpgSaveOptions, true, Extension.LOWERCASE);
} else {
alert("You must have a document open to use this script!");
}
Copy link to clipboard
Copied
Somehow fixed it by rerecording the Actions 🙂
Copy link to clipboard
Copied
Now I can quickly crop and with a single Fkey can save and close and do the next.
Thank you so much for this. Youre a star