Copy link to clipboard
Copied
here is script which save document as .psd. In this script i have to enter name manually. Please guide me what should I change so that clipboard text automatically get pasted in text area of dailoge box shown in screenshot. One of my friend told me to use
function pasteit(theField)
{document.execCommand('Paste');
}
but I dont know where i should put this
Second : in output folder If there is already a psd file with same name than can we save new psd with sequence number.
Here is script
//////////////////////
try{
//Code you want to execute
if (app.documents.length > 0) {
var myDoc = app.activeDocument;
var myDocName = myDoc.name;
var myFolder = new Folder('~/Desktop/output'); // change location to your own folder
if (!myFolder.exists) myFolder.create();
var myDialog = new Window('dialog', 'GIVE NAME FOR THIS PSD');
myDialog.size = {width:400, height:100};
var myEditText = myDialog.add('edittext');
myEditText.active = true;
myEditText.preferredSize = {width:200, height:20};
var myNewName = myEditText.text;
var myGroup = myDialog.add('group');
myGroup.orientation = 'row';
var myOkBtn = myGroup.add('button', undefined, 'Save', {name:'ok'});
var myCancelBtn = myGroup.add('button', undefined, 'Cancel', {name:'cancel'});
if (myDialog.show() == 1) {
var myNewName = myEditText.text;
if (myNewName != "") {
myNewName += '.psd';
var myNewFile = new File(myFolder.fsName + '/' + myNewName);
var id51 = charIDToTypeID( "save" );
var desc8 = new ActionDescriptor();
var id52 = charIDToTypeID( "As " );
var desc9 = new ActionDescriptor();
var id53 = stringIDToTypeID( "maximizeCompatibility" );
desc9.putBoolean( id53, true );
var id54 = charIDToTypeID( "Pht3" );
desc8.putObject( id52, id54, desc9 );
var id55 = charIDToTypeID( "In " );
desc8.putPath( id55, new File( myNewFile ) );
var id56 = charIDToTypeID( "LwCs" );
desc8.putBoolean( id56, true );
executeAction( id51, desc8, DialogModes.NO );
var myLastPsd = app.activeDocument.fullName.toSource();
try {
var myPrefsFolder = new Folder( Folder.userData.absoluteURI + '/TempScriptData' );
if (!myPrefsFolder.exists) myPrefsFolder.create();
var myTempFile = new File(myPrefsFolder.fsName + '/TempData.txt');
myTempFile.open("w");
myTempFile.write(myLastPsd);
myTempFile.close();
}
catch (err) {
alert("Failed to create a temp file. -- Error: " + err.message);
exit();
}
}
}
}
else {
alert("THERE IS NO PSD DOCUMENT OPEN.");
}
}catch(e){
//If Code didn't execute then goes here, and executes code within this block
}
////////////
Thanks & have a nice day
Copy link to clipboard
Copied
I don't understand the workflow you are trying to make. How would pasting text from clipboard save you time or automate your process. Won't you have to copy the correct information before running the script? If that is so why not type in the text? Or if this has to run in batch mode you could either edit the script with the path as input before running or modify the script to work with an input file and make the name changes in that input file
-Manan
Copy link to clipboard
Copied
I have thousands of psd files with randum names. Each psd contains around 50-60 frame layers few of them are vertical few of them are horizontal. I have one script which calculate the number of vertical frames and horizontal frames and copy the output in clipboard like 25V40H (it means psd contain 25vertical frame and 40 horizontal frame). I want to catagorise all the psd by new names so that I could easily search them when needed without counting all the frame layer. If there is no way we can paste clipboard text to that text area than its fine I can write manually. I thought anyone could help so posted. if there is any other solution for what i am trying to achieve than please suggest.
Copy link to clipboard
Copied
You can not do that. There is no way a script can target a input field in a Photoshop ScriptUI dialog and use paste. I also do not know if a Photoshop script can test to see if there is text in the clipboard and the text would be valid file name. If the script can get text from the clipboard that would be a valid file name. The script would not need a dialog. It would just use the name it got from the clipboard and test if that file exists and the do the proper save you want.
You need to add the save logic to the script that develop the file name you want it needs to do the save save you want not put text in the clipboard. How does the script copy text to the keyboard in the first script. Its easy to develop the name you want use it to do the save you want. Or use Fiee System commands to rename the existing file on disk to have the name you want it to have. Why would you want duplicate image file with different names on disk? How would you be able to keep the files the same if you need to update an image.
Copy link to clipboard
Copied
Thank you JJMack sir...I just wanted to modify the script. If dialog box with inut field not needed than please guide what changes required in given script so that It could save the psd with clipboard text name and if there is a psd file with same name already in output folder how to add sequence number in it clipboard text so that it wont overwrite .
Thanks in advance
Copy link to clipboard
Copied
You need to add the save logic to the script that develop the file name you want it needs to do the save save you want not put text in the clipboard. How does the script copy text to the keyboard in the first script. Its easy to develop the name you want use it to do the save you want. Or use Fiee System commands to rename the existing file on disk to have the name you want it to have. Why would you want duplicate image file with different names on disk? How would you be able to keep the files the same if you need to update an image.
Copy link to clipboard
Copied
For me, the big question is, how does the text get into the clipboard in the first place? This is not clear to me. Is it from that other topic thread where r-bin wrote a script for you?
As demonstrated in one of your other related topic threads, you may not need to use the clipboard, as in that example you wanted to use a specific layer in the open file, so the script just uses the layer name directly without even using the clipboard.o
Copy link to clipboard
Copied
This is really a simple exercise in logic. You obviously want to batch this process. You should not want to have duplicate image files with different file name. It would be a wast of disk space and a maintainers nightmare to keep the files identical. Also you should not want your batching process to rename existing image files that have the name you want the batch process should just leave these files as they are and rename the other image files to have the names you wand not create duplicate image file with a different name. If you want to be able to search your images I am surprised that you are not using Lightroom for its Image Library system or Adobe bridge where you can create collections, filter on meta data to select images. Using a file naming convention will not be as robust or as versatile as an Image library system or a good image organiser. Files can have any name if you can search on image meta data. Your Batch process could leave all file names be and just edit the image files's meta data so you have a way to search your image file collection for a particular type of image. You could add many keywords for difference image characteristic. A file naming convention is not very flexible it would be quite limited and hard to change.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now