Yet Another Incremental Save Question....
Hi there.. I am trying to get incremental save working in a way that can be placed into a ACTION.
Basically I am scanning a large number of small items (over 3000), and I can fit 18 on the scanner at once. If I use the "Straiten and Crop" script the scanned file gets straitened and cropped nicely.
I made an Action that loads the scans from a folder and runs the straiten and crop script, then dose some editing to the cropped image, saves it and then closes it. This "edit/save/close" repeats until all the images are processed from the original scan.
The problem is that no matter what I do the save file in the batch is always the same, or askes for over write. What I would like is a very simple script that saves a increment number on each save file. There is a lot of threads on this, but the only one I could get working had this script in it...
| // This script will save the active document to a folder with an incremental sufix | |
| // Change the options below to match your needs | |
| var saveFolder = new Folder( 'C:\\test' ); | |
| var saveExt = 'jpg'; | |
| var saveSufixStart = '_'; | |
| var saveSufixLength = 3; | |
| jpgSaveOptions = new JPEGSaveOptions(); | |
| jpgSaveOptions.embedColorProfile = true; | |
| jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; | |
| jpgSaveOptions.matte = MatteType.NONE; | |
| jpgSaveOptions.quality = 8; | |
| // End of user options | |
| //========================================== | |
| function zeroPad ( num, digit ){ | |
| var tmp = num.toString(); | |
| while (tmp.length < digit) { tmp = "0" + tmp;} | |
| return tmp; | |
| } | |
| var docName = decodeURI ( activeDocument.name ); | |
| docName = docName.match( /(.*)(\.[^\.]+)/ ) ? docName = docName.match( /(.*)(\.[^\.]+)/ ) : docName = [ docName, docName, undefined ]; | |
| var saveName = docName[ 1 ]; // activeDocument name with out ext | |
| var files = saveFolder.getFiles( saveName + '*.' + saveExt );// get an array of files matching doc name prefix | |
| var saveNumber = files.length + 1; | |
| //alert("New file number: " + zeroPad( saveNumber, saveSufixLength )); | |
| var saveFile = new File( saveFolder + '/' + saveName + '_' + zeroPad( saveNumber, saveSufixLength ) + '.' + saveExt ); | |
| activeDocument.saveAs( saveFile, jpgSaveOptions ,true ,Extension.LOWERCASE); |
This seams to work fine.. but there are some problems, and I am just a simple paint, scan manipulate type guy and no idea how to improve it...
1) - It only saves into "c:\test". I have tried pasting other paths in there.. like "d:\projects\project name\scans\processed\" but it doesn't help.
2) - The Straiten and Crop Script works fine called from an action. So I can make a single action to process the file. The script above works fine in an action along with the editing actions. The problem is if I call the editing / save action from the "open/straiten and crop" action, then the script dosn't error but I can not find the files it is suposed to make (probably got a billion jpgs lost on my drive somewhere now)
If anyone can help with this I would be appreciative.
Thanks!
