Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

Script to save as tif with zip compression, file name from properties

Community Beginner ,
Apr 02, 2016 Apr 02, 2016

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.

TOPICS
Actions and scripting
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Apr 02, 2016 Apr 02, 2016

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

...
Translate
Adobe
Guide ,
Apr 02, 2016 Apr 02, 2016

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);

};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 02, 2016 Apr 02, 2016

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 02, 2016 Apr 02, 2016

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);

};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 02, 2016 Apr 02, 2016

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

  1. var fileName =activeDocument.info.title;
  2. var saveFile = new File("d:/" + fileName + ".tif");
  3. tiffSaveOptions = new TiffSaveOptions();
  4. tiffSaveOptions.embedColorProfile = true;
  5. tiffSaveOptions.alphaChannels = true;
  6. tiffSaveOptions.layers = true;
  7. tiffSaveOptions.imageCompression = TIFFEncoding.TIFFZIP;
  8. activeDocument.saveAs(saveFile, TiffSaveOptions, true, Extension.LOWERCASE);

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 02, 2016 Apr 02, 2016

Sorry one more thing how would it deal with duplicates? I would like it to add a number on the end instead of overwriting

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 02, 2016 Apr 02, 2016

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);

};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 02, 2016 Apr 02, 2016

This overrides files with the same name is it possible to prevent this?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 02, 2016 Apr 02, 2016

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();

};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 02, 2016 Apr 02, 2016
LATEST

Thank you that worked a treat

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 02, 2016 Apr 02, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 02, 2016 Apr 02, 2016

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"));}}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines