Copy link to clipboard
Copied
Hello,
iam looking for a solution to open files in a folder
and copy then into a document.
Its working good, but i need the files to be linked smart object.
Anyone knows a solution ?
Here my Code so far:
See in line 33. Convert to smart object: ?
var file = new File('C:/User_MY PATH.PSD'),
docRef = open(file);
// Use the path to the application and append the samples folder
var samplesFolder = Folder('C:/USERS_MY FOLDER');
//Get all the files in the folder
var fileList = samplesFolder.getFiles()
// open each file
for (var i = 0; i < fileList.length; i++)
{
// The fileList is folders and files so open only files
if (fileListinstanceof File)
{
open(fileList)
// use the document name for the layer name in the merged document
var activeDocName = app.activeDocument.name;
var targetDocName = activeDocName.substring(0, activeDocName.lastIndexOf("."));
// Copy the Document
app.activeDocument.selection.selectAll()
//convertToSmartObject(); THIS ISNT WORKING - CONVERT IT ?
app.activeDocument.selection.copy()
// don’t save anything we did
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES)
//Select specific layer to paste the copy, this is to make sure the layers are in a specific position
var doc = app.activeDocument;
doc.activeLayer = doc.artLayers.getByName("bgr");
//Paste Document
app.activeDocument.paste()
app.activeDocument.activeLayer.name = targetDocName
}
};
Use scriptlistener:
...var idPlc = charIDToTypeID( "Plc " );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
desc2.putPath( idnull, new File( "C:\\Photos\\myPhoto.psd" ) );
var idLnkd = charIDToTypeID( "Lnkd" );
desc2.putBoolean( idLnkd, true );
var idFTcs = charIDToTypeID( "FTcs" );
var idQCSt = charIDToTypeID( "QCSt" );
var idQcsa = charIDToTypeID( "Qcsa" );
desc2.putEnumerated( idFTcs, idQCSt, idQcsa );
var idOfst = charIDToTypeI
Copy link to clipboard
Copied
Use scriptlistener:
var idPlc = charIDToTypeID( "Plc " );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
desc2.putPath( idnull, new File( "C:\\Photos\\myPhoto.psd" ) );
var idLnkd = charIDToTypeID( "Lnkd" );
desc2.putBoolean( idLnkd, true );
var idFTcs = charIDToTypeID( "FTcs" );
var idQCSt = charIDToTypeID( "QCSt" );
var idQcsa = charIDToTypeID( "Qcsa" );
desc2.putEnumerated( idFTcs, idQCSt, idQcsa );
var idOfst = charIDToTypeID( "Ofst" );
var desc3 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc3.putUnitDouble( idHrzn, idPxl, 0.000000 );
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc3.putUnitDouble( idVrtc, idPxl, 0.000000 );
var idOfst = charIDToTypeID( "Ofst" );
desc2.putObject( idOfst, idOfst, desc3 );
executeAction( idPlc, desc2, DialogModes.NO );
Copy link to clipboard
Copied
This is working, but i want to read in a whole folder
not a specific file. I have to look into it - thanks again!
Copy link to clipboard
Copied
Also you should be able to use application.open(file, OpenDocumentType.PHOTOSHOP, true) to open a file as a smart object and the duplicate it to your target doc. If you do the same in UI, it should create a linked smart object.
Copy link to clipboard
Copied
Its working for Smart Object - but it didnt convert it to LINKED one.
Also therre is a small Problem, that i copy the selection - i have to copy/duplicate the layer.
Thanks,
Alpha
Copy link to clipboard
Copied
You are right, it's not linked even if you use "File->Open as Smart Object".. Doesn't seem to be a way in API to create linked ones
Copy link to clipboard
Copied
Using the scriptlistener as I mentioned above works fine to place a file as a linked SO. Just replace the file name with a variable in line 4.
Copy link to clipboard
Copied
Yes, that's why you put the scriptlistener code in a function and send that function a variable with each of the file's paths from the folder.
Copy link to clipboard
Copied
thanks - thats it
Copy link to clipboard
Copied
Hi there,
It but it would be very useful to me too.
As I'm not familiar with scripting in photoshop, I have hard time to read the code, especially the one Chuck Uebele posted, as it looks less beginner friendly than the Alphavader posted in the first place.
My question is : Is there anyone that finalize the script ? (preferably with comments in the code...)
Thanks for reading !