Hi folks,
I am going to be sending thousands of files out for clipping. 90% of the files I will be sending won't have a clipping path but a few in the mix will already have been clipped.
I am selecting the files using the "Find and Save" script from PS-Scripts.
Find and Save
Code: Select allfunction main() {
//Ask the user to select the comma-delimited file
var csvFile = File.openDialog("Open Comma-delimited File","comma-delimited(*.csv):*.csv;");
//Make sure the comma-delimited file exists and then open it
datafile = new File(csvFile);
if (datafile.exists)
{ datafile.open('r') ;
};
var csvString = datafile.read();
csvString = csvString.toLowerCase();// lets avoid Case mismatches
datafile.close();
// Select folder to search in
var searchFolder = Folder.selectDialog ("Select folder to search in")
// Select folder to save files
var saveFolder = Folder.selectDialog ("Select folder to save files")
var searchFiles = searchFolder.getFiles();
for(var i=0;i<searchFiles.length;i++){
if(csvString.indexOf(searchFiles.name.toLowerCase()) != -1){
//there is a match between the csv and folder
var newFilepath = saveFolder.fullName+"/"+searchFiles.name;
if( saveFolder.exists ){
var newFile = new File(newFilepath);
searchFiles.copy(newFile); // copy file to new location
}
}
}
};
main();
This is also the script that I had mentioned in my recent post http://ps-scripts.com/bb/viewtopic.php? ... CSV#p25888.
So my thoughts were that either
1. I could grab all the files on my CSV list and then check and log which have paths with the script I just requested and then remove them possibly using the "Find and Delete" script http://ps-scripts.com/bb/viewtopic.php? ... CSV#p25839.
2. Include in the Find and Save script something that would ignore a file if it had a path but log it so I knew why it wasn't included with the found images.
If anyone has any ideas I'd love to hear them. (A script would be nice too )
I can't imagine doing what I do without the help I have had from you guys.
Long live PS-Scripts!
Cheers!
Limey (Paul)
Check files for path and write to log
-
Mike Hale
Check files for path and write to log
Hi Paul,
Maybe I am just being dim-witted today but I don't understand where the check for clipping path comes in or what exactly you want to log?
Do you just want to be able to search a folder for files that already have a clipping path and move those to a different folder so you will not send off files that already have a clipping path?
Maybe I am just being dim-witted today but I don't understand where the check for clipping path comes in or what exactly you want to log?
Do you just want to be able to search a folder for files that already have a clipping path and move those to a different folder so you will not send off files that already have a clipping path?
-
Limey
Check files for path and write to log
Do you just want to be able to search a folder for files that already have a clipping path and move those to a different folder so you will not send off files that already have a clipping path?
That would work just fine Mike! Actually that's better than what I was asking for. I was asking to check to see what files had an instance a path and log it so I could remove it. What you have mentioned would find the files with paths and move them to a different folder where I can get rid of them as needed. We have all the original images still on our server. These are just copies I am working with.
Even if it's a script that works on a single file I could put it into an action and make a droplet. I think then I could drag a file, multiple files or even a folder to it to be processed. Right? No Log needed
Thanks Mike!
Paul
That would work just fine Mike! Actually that's better than what I was asking for. I was asking to check to see what files had an instance a path and log it so I could remove it. What you have mentioned would find the files with paths and move them to a different folder where I can get rid of them as needed. We have all the original images still on our server. These are just copies I am working with.
Even if it's a script that works on a single file I could put it into an action and make a droplet. I think then I could drag a file, multiple files or even a folder to it to be processed. Right? No Log needed
Thanks Mike!
Paul
-
Mike Hale
Check files for path and write to log
Just so I am clear - are we talking about Photoshop clipping path, the work path, or a normal path? Knowing which type you want to search for will tell me which image resource ID to use.
-
Limey
Check files for path and write to log
Mike, I am referring to any path that would show up in the paths palette whether it be an unsaved "work path" or saved "Path 1" etc. I'm not referring to setting the clipping path in the paths palette fly out menu.
Sorry to take so long to get back to you. it was a busy day at the office and I had my kids with me tonight.
Thanks again Mike!
Paul
Sorry to take so long to get back to you. it was a busy day at the office and I had my kids with me tonight.
Thanks again Mike!
Paul
-
Mike Hale
Check files for path and write to log
Try this. Note the files need to either be created in Photoshop or at least saved once by Photoshop as this counts on Photoshop Image Resource IDs being present in the file to determine if it has a path.
Code: Select allfunction main() {
var searchFolder = Folder.selectDialog ("Select folder to search in")
// Select folder to save files
var saveFolder = Folder.selectDialog ("Select folder to save files")
var searchFiles = searchFolder.getFiles(/\.(jpg|tif|psd)$/i);// would be faster to limit file formats with search mask
for(var i=0;i<searchFiles.length;i++){
searchFiles = getPhotoshopPathInfo( searchFiles );
var moveFile = false;
if(searchFiles.hasPhotoshopWorkPath) moveFile = true;
if(searchFiles.hasPhotoshopSavedPath) moveFile = true;
if( moveFile && saveFolder.exists ){
var newFilepath = saveFolder.fullName+"/"+searchFiles.name;
searchFiles.copy(newFilepath); // copy file to new location
}
}
};
main();
function getPhotoshopPathInfo( fileObject ){
var clippingPathTag = '8BIM\x0B\xB7';
var workPathTag = '8BIM\x04\x01';
var firstSavedPathTag = '8BIM\x07\xD0';
fileObject.open('r');
fileObject.encoding = 'BINARY';
var str = fileObject.read();
fileObject.close();
fileObject.hasPhotoshopClippingPath = str.search(clippingPathTag) == -1 ? false:true;
fileObject.hasPhotoshopWorkPath = str.search(workPathTag) == -1 ? false:true;
fileObject.hasPhotoshopSavedPath = str.search(firstSavedPathTag) == -1 ? false:true;
return fileObject;
}
Code: Select allfunction main() {
var searchFolder = Folder.selectDialog ("Select folder to search in")
// Select folder to save files
var saveFolder = Folder.selectDialog ("Select folder to save files")
var searchFiles = searchFolder.getFiles(/\.(jpg|tif|psd)$/i);// would be faster to limit file formats with search mask
for(var i=0;i<searchFiles.length;i++){
searchFiles = getPhotoshopPathInfo( searchFiles );
var moveFile = false;
if(searchFiles.hasPhotoshopWorkPath) moveFile = true;
if(searchFiles.hasPhotoshopSavedPath) moveFile = true;
if( moveFile && saveFolder.exists ){
var newFilepath = saveFolder.fullName+"/"+searchFiles.name;
searchFiles.copy(newFilepath); // copy file to new location
}
}
};
main();
function getPhotoshopPathInfo( fileObject ){
var clippingPathTag = '8BIM\x0B\xB7';
var workPathTag = '8BIM\x04\x01';
var firstSavedPathTag = '8BIM\x07\xD0';
fileObject.open('r');
fileObject.encoding = 'BINARY';
var str = fileObject.read();
fileObject.close();
fileObject.hasPhotoshopClippingPath = str.search(clippingPathTag) == -1 ? false:true;
fileObject.hasPhotoshopWorkPath = str.search(workPathTag) == -1 ? false:true;
fileObject.hasPhotoshopSavedPath = str.search(firstSavedPathTag) == -1 ? false:true;
return fileObject;
}
-
Limey
Check files for path and write to log
That's great Mike... All our files are processed in Photoshop. I can't wait to run this on Monday when I get into the office.
Many thanks,
Paul
Many thanks,
Paul