Copy link to clipboard
Copied
I don't know anything about scripting so I am unable to understand the answers to similar questions and merge an answer for mine.
I am looking for a script to save my scanned images as tiff with zip compression using the Document Title from the file properties.
I want to assign it to a button to save me time, Scanning images takes enough time as it is
Thank you in advance for any help.
If the file exists this will append the time so it will be a different file name.
#target photoshop;
main();
function main(){
var Path = Folder("/D/Scanned");
if(!Path.exists){
alert(Path + " does not exist!");
return;
}
var fileName =activeDocument.info.title;
if(fileName == '') {
alert("There is no title in this document");
return;
}
var saveFile = File(Path + "/" + fileName + ".tif");
if(saveFile.exists) saveFile = File(Path + "/" + fileName +"-" + time() + ".tif");
SaveTIFF(saveFil
...Copy link to clipboard
Copied
Try this.
#target photoshop;
main();
function main(){
try{
var Path = activeDocument.path;
}catch(e){
alert("This document needs to have been saved before running this script!");
return;
}
var fileName =activeDocument.info.title;
if(fileName == '') {
alert("There is no title in this document");
return;
}
var saveFile = File(Path + "/" + fileName + ".tif");
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
};
function SaveTIFF(saveFile){
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
tiffSaveOptions.alphaChannels = true;
tiffSaveOptions.layers = true;
tiffSaveOptions.imageCompression = TIFFEncoding.TIFFZIP;
activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
};
Copy link to clipboard
Copied
Thank you for the quick reply.
I have tried the script but I need to save it before running the script. I was hoping to use the script as a Save as is that possible?
Copy link to clipboard
Copied
This will prompt you for the output folder.
#target photoshop;
main();
function main(){
var Path = Folder.selectDialog( "Please select output folder");
if(Path == null){
alert("You need to select an output folder!");
return;
}
var fileName =activeDocument.info.title;
if(fileName == '') {
alert("There is no title in this document");
return;
}
var saveFile = File(Path + "/" + fileName + ".tif");
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
};
function SaveTIFF(saveFile){
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
tiffSaveOptions.alphaChannels = true;
tiffSaveOptions.layers = true;
tiffSaveOptions.imageCompression = TIFFEncoding.TIFFZIP;
activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
};
Copy link to clipboard
Copied
Thank you again. I am able to select to location but it doesn't save.
I removed app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); because it just closed without saving. The location I am saving id D:\Scanned Images
After figuring some of it out I got this from a different thread and the answer you supplied
This creates the file as I wanted, The problem is I can not get a if else command to work like the one from your code "
if(fileName == '') {
alert("There is no title in this document");
return;
}
"
Was I right saving it as a .jsx I first saved it as .vbr but while trying to learn what I was reading I figured it was Javascript
Copy link to clipboard
Copied
Sorry one more thing how would it deal with duplicates? I would like it to add a number on the end instead of overwriting
Copy link to clipboard
Copied
This should now as I have tested this version.
There is no prompt it just saves to the scanned folder.
Yes it should be a jsx file.
#target photoshop;
main();
function main(){
var Path = Folder("/D/Scanned");
if(!Path.exists){
alert(Path + " does not exist!");
return;
}
var fileName =activeDocument.info.title;
if(fileName == '') {
alert("There is no title in this document");
return;
}
var saveFile = File(Path + "/" + fileName + ".tif");
SaveTIFF(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
};
function SaveTIFF(saveFile){
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
tiffSaveOptions.alphaChannels = true;
tiffSaveOptions.layers = true;
tiffSaveOptions.imageCompression = TIFFEncoding.TIFFZIP;
activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
};
Copy link to clipboard
Copied
This overrides files with the same name is it possible to prevent this?
Copy link to clipboard
Copied
If the file exists this will append the time so it will be a different file name.
#target photoshop;
main();
function main(){
var Path = Folder("/D/Scanned");
if(!Path.exists){
alert(Path + " does not exist!");
return;
}
var fileName =activeDocument.info.title;
if(fileName == '') {
alert("There is no title in this document");
return;
}
var saveFile = File(Path + "/" + fileName + ".tif");
if(saveFile.exists) saveFile = File(Path + "/" + fileName +"-" + time() + ".tif");
SaveTIFF(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
};
function SaveTIFF(saveFile){
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
tiffSaveOptions.alphaChannels = true;
tiffSaveOptions.layers = true;
tiffSaveOptions.imageCompression = TIFFEncoding.TIFFZIP;
activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
};
function time(){
var date = new Date();
var d = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
var digital = new Date();
var hours = digital.getHours();
var minutes = digital.getMinutes();
var seconds = digital.getSeconds();
var amOrPm = "AM";
if (hours > 11) amOrPm = "PM";
if (hours > 12) hours = hours - 12;
if (hours == 0) hours = 12;
if (minutes <= 9) minutes = "0" + minutes;
if (seconds <= 9) seconds = "0" + seconds;
todaysDate = hours + "-" + minutes + "-" + seconds + amOrPm;
return todaysDate.toString();
};
Copy link to clipboard
Copied
Thank you that worked a treat
Copy link to clipboard
Copied
Goin to add a time stamp to the end of it when I look at it tomorrow changing the code adds numbers to the end will google time stamp then
var thistimestamp = Math.round(new Date().getTime() / 1000);
var saveFile = File(Path + "/" + fileName + "--" + thistimestamp +".tif");
SaveTIFF(saveFile);
Thank you for the time you have spent helping me
Copy link to clipboard
Copied
On an other subject do you use Adobe Configurator?
I am using VueScan and want to speed up my scanning by using Adobe Configurator to create a easy access button. However the option isnt there. I was wondering if you knew what the script would be? Below is the code for inserting a note. I think I need to edit the 'importAnnots' but not sure what to
ErrStrs = {}; ErrStrs.USER_CANCELLED=localize("$$$/ScriptingSupport/Error/UserCancelled=User cancelled the operation"); try {var idimportAnnots = stringIDToTypeID( 'importAnnots' ); var desc1085 = new ActionDescriptor(); executeAction( idimportAnnots, desc1085, DialogModes.ALL ); } catch(e){if (e.toString().indexOf(ErrStrs.USER_CANCELLED)!=-1) {;} else{alert(localize("$$$/ScriptingSupport/Error/CommandNotAvailable=The command is currently not available"));}}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now