Quick Save as Versions with Script?

I'm looking to modify a script I found online but unfortunately I don't know enough Javascript to figure it out.
Here's the original code from this blog post:
#target photoshop;
if (app.documents.length > 0) {
var thedoc = app.activeDocument;
  var docName = thedoc.name;
if (docName.indexOf(".") != -1) {
  var basename = docName.match(/(.*)\.[^\.]+$/)[1]
} else {
  var basename = docName
  //getting the location, if unsaved save to desktop;
try {
  var docPath = thedoc.path
} catch (e) {
  var docPath = "~/Desktop"
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 9;
jpegOptions.embedColorProfile = true;
jpegOptions.matte = MatteType.NONE;
var filename = docPath + '/' + basename + "-" + getTime() + '.jpg';
  thedoc.saveAs((new File(filename)), jpegOptions, true);
function getTime(){
var currentTime = new Date();
  //Make single-digit mins show up as 6:01 and not 6:1
var minutes = currentTime.getMinutes();
if (minutes < 10) {
  minutes = "0" + minutes;
  var timeStamp = currentTime.getFullYear() + "-"
     + (currentTime.getMonth() + 1) + "-"
     + currentTime.getDate() + "-"
     + currentTime.getHours() + "."
     + minutes + "."
     + currentTime.getSeconds() + "."
     + currentTime.getMilliseconds();
return timeStamp;
What I'm trying to do is instead of saving with a timestamp, I'd rather have the script automatically detect the most recent version (eg: MyPicture_04.jpg) and save as the next logical increment (eg: MyPicture_05.jpg)
Anyone know how I'd be able to go about scripting that?
Thanks!

Hey, thanks for your help.
When I loaded your script it would revoke some of the naming of my original file, but with some tinkering I got it to work, but there are still some problems. One is it only saves one copy and then it'll just overwrite it...and the other is that when I'm creating the first save, my file comes out as 3LINE_V2_02a_NaN.jpg (bold is the part the script creates, the rest is my filename) and then after that it'll just overwrite it. Here's the script I have atm:
#target photoshop;
if (app.documents.length > 0) {
var thedoc = app.activeDocument;
  var docName = thedoc.name;
if (docName.indexOf(".") != -1) {
  var basename = docName.match(/(.*)\.[^\.]+$/)[1]
} else {
  var basename = docName
  if (docName.indexOf(".") != -1) {
   var basename = docName.match(/(.*)\.[^\.]+$/)[1]
  } else {
   var basename = docName
  var baseArray = basename.split("_")
  var imgNumStr = baseArray[baseArray.length-1]
  var replaceNum = Number (imgNumStr) + 1000000001
  var replaceStr = replaceNum.toString().substr (replaceNum.toString().length-imgNumStr.toString().length, imgNumStr.toString().length)
  var nameBeg = basename.substr(0,basename.length-replaceStr.length)
  if(Number (replaceStr)==0)
  {replaceStr = replaceNum.toString().substr (replaceNum.toString().length-imgNumStr.toString().length-1, imgNumStr.toString().length+1)}
  //getting the location, if unsaved save to desktop;
try {
  var docPath = thedoc.path
} catch (e) {
  var docPath = "~/Desktop"
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 10;
jpegOptions.embedColorProfile = true;
jpegOptions.matte = MatteType.NONE;
var filename = docPath + '/' + basename + "_" + replaceStr + '.jpg';
  thedoc.saveAs((new File(filename)), jpegOptions, true);
function getTime(){
var currentTime = new Date();
  //Make single-digit mins show up as 6:01 and not 6:1
var minutes = currentTime.getMinutes();
if (minutes < 10) {
  minutes = "0" + minutes;
  //Make single-digit hours show up as 06:01 and not 6:1
var hours = currentTime.getHours();
if (hours < 10) {
  hours = "0" + hours;
  var timeStamp = currentTime.getFullYear() + "_"
     + (currentTime.getMonth() + 1) + "_"
     + currentTime.getDate() + "_"
     + currentTime.getHours() + "_"
     + minutes + "_"
     + currentTime.getSeconds()
return timeStamp;

Similar Messages

  • Change Illustrator version with scripting?

    Hello!
    I go through several dozen files a day at work and we have to save down everything to 9 as we go.
    Actions don't seem to delve that deep into the save as promt, so how can I script this so that the default goes to Version Illustrator 9 everytime?
    I'm looking to do a similar script while exporting my format as default jpeg instead of png.
    Help anyone on where to point me?  I'm familiar with the basics of scripting.  It's been a while but I need a starting point on if this is even possible.
    Thanks!

    I found the Applescript from Larry G. Schneider to be a great solution . . . ALMOST.  Seems like Adobe has abandoned the info Finder uses, the "file type." So I added another few lines that ALSO recognize files whose "kind" is "Adobe Illustrator Document."
    Here's the code. (NOTE: This version is suited to my prefs, which is to resave as CS4. For your purposes, you would simple edit the script, changing "compatibility:Illustrator 14" to "compatibility:Illustrator 9" .)
    -- BEGIN CODE:
    set fileTypes to {"EPSF", "PDF ", "ART5", "TEXT"} -- file types available to resave as Illustrator
    -- get a sourceFolder that holds the files to resave as AI
    set sourceFolder to (choose folder with prompt "Choose a folder with files to resave as Illustrator CS4:") as text
    -- get a list of files of the defined type in the sourceFolder
    tell application "Finder" to set workingFiles to (every file of folder sourceFolder whose file type is in fileTypes) as alias list
    -- now you have your fileList argument
    -- look again, getting AI docs whose "file type" is missing (due, presumably, to CS file format changes):
    tell application "Finder" to set moreFiles to (every file of folder sourceFolder whose kind is "Adobe Illustrator Document") as alias list
    set workingFiles to workingFiles & moreFiles
    -- get a destinationFolder to hold the new files
    set destinationFolder to choose folder with prompt "Choose a folder to hold the Illustrator files:"
    SaveFilesAsIllustrator14(workingFiles, destinationFolder)
    on SaveFilesAsIllustrator14(fileList, destinationFolder)
    set destinationPath to destinationFolder as string
    repeat with aFile in fileList
    tell application "Finder"
    set fileName to displayed name of aFile -- get displayed name
    set AppleScript's text item delimiters to "."
    set newFileName to text item 1 of fileName
    set newFilePath to destinationPath & newFileName & ".ai"
    end tell
    tell application "Adobe Illustrator"
    open aFile forcing CMYK with options {update legacy text:true}
    -- amend the "compatibility:" value to your preference (which might be followed up by amending some of the above lines, esp. the prompt in line 4):
    compatibility (Illustrator 10/Illustrator 11/Illustrator 12/Illustrator 13/Illustrator 14/Illustrator 3/Illustrator 8/Illustrator 9/Japanese 3) : what Illustrator file format version to create ( default: Illustrator 14 )
    save current document in file newFilePath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 14, embed linked files:true, font subset threshold:0.0}
    close current document saving no
    end tell
    end repeat
    end SaveFilesAsIllustrator14
    -- END CODE

  • Notes app saves new version with every edit?

    This is odd. In the new notes app every time I edit a note (or even while I am creating it...virtually every time I hit return) a new version of the note gets save. Typing a short note gets 15 versions in the sidebar (like the enclosed pic)
    Is this how it is supposed to act? Has my syncing gone-wild?

    ok, I just found a way to fix it.
    For some reason Notes app did nto get along with Gmail. As soon as I went to preferences -> Mail, Contacts & Calendars and removed notes from Gmails (and added it to iCloud) everything started behaving normally.
    Go figure...but sounds about right, Apple Mail and Gmail have always had a love/hate relationship, not surprised the configuration difficulty has extended to notes also...

  • Does auto-save and version work with old apps like pages '09?

    Hello,
    I'm new Lion user. I tried auto-save and version with textedit and it works.
    But i'm not sure it works with pages '09.

    It does work if you install the update from yesterday.

  • I need to create an action or script to save the file with the name of the selected layer

    I need to create an action or script to save the file with the name of the selected layer (not including the hidden layers, but including those visible).
    How could modify the script: 'Layer Comps To Files.jsx' to get the result?
    Warning: I do not need to export all layers as files.
    Who can help me?
    THX in advance

    Versione in Italiano (Further down the English version)
    NB - Nella versione inglese ho messo tutte le immagini dei menu in italiano.
    Versione per Mac, ma credo sia identico per Windows.
    Spiego passo passo cosa ho fatto:
    - Ho creato un file esempio con tre Livelli, salvato sulla scrivania e ho chiuso il file.
    - Ho aperto il file e selezionato il Livello al centro per iniziare a registrare una azione che ho chiamato: Save with Name of Selected Layer
    - Nuova azione
    - Dare il nome e premere Registra
    Ora salva…
    - Menu --> Livello --> Nuovo --> Livello... e premi -ok-, (lascia il nome che viene mostrato)
    - Ancora una volta Menu --> Livello... --> Nuovo --> Livello... e premi -ok-, (lascia il nome che viene mostrato)
    - Menu --> Livello --> Ordina --> Dietro
    - Menu --> Livello --> Unisci sotto
    - Menu --> Livello --> Unisci visibili
    - Menu --> Livello --> Nuovo --> Livello... e premi -ok-, (lascia il nome che viene mostrato)
    - Menu --> Livello - Nascondi Livello
    - Menu --> Elimina --> Elimina livelli nascosti (press -Yes-)
    - Menu --> Livello --> Nuovo --> Livello... Inserisci questo: 'Move this to the trash' e premi ok
    - Menu --> File --> Script --> Esporta Livelli in File... (Nella finestra che si apre scegliere l’opzione che si desidera, ma togliere il prefisso del nome) e premere -Esegui-
    - Selezionare il pannello Storia cliccare su Elimina premendo -Si- ogni volta che si apre la finestra di dialogo (Ripetere 8 volte questa operazione sino ad arrivare nella storia alla condizione di partenza. Ho visto che è meglio di Ripristina -F12-)
    - Fermare la registrazione.
    A questo punto, mandando in esecuzione questa Azione, ho raggiunto parzialmente l’obiettivo perché i file così creati mantengono, purtroppo, dei prefissi numerici per evitare probabilmente la sovrascrizione di file (credo senza avviso) nel posto dove vengono creati.
    Per ottenere l’obiettivo occorre un nuovo passo ed a proposito di questo riferisco quanto segue:
    ATTENZIONE - L’operazione descritta qui di seguito deve essere fatta su di una copia del file, per cui:
    - Duplicare il file,
    - Spostare l’originale in altra cartella
    - Lavorare sul file duplicato.
    mi riferisco a questo...
    ATTENZIONE - Questa modifica è effettuata a proprio rischio e pericolo ed il sottoscritto non si assume alcuna responsabilità su quanto venga fatto soprattutto da mani inesperte.
    ATTENZIONE - Questa modifica sovrascrive qualsiasi file che abbia nome uguale al layer che viene selezionato più l’estensione del file naturalmente.
    Comunque la modifica è banalissima e a portata di chiunque.
    Procedere così:
    - Chiudere Photoshop
    - Aprire (nel percorso specificato dall’immagine) il file “Export Layers to Files.jsx” (Export Layers To Files.jsx 1.0.0.16) con un editor di testo puro.
    - cercare la stringa (dovrebbe essere in riga 1029)
    var fileNameBody = fileNamePrefix;
    fileNameBody += "_" + zeroSuppress(i, 4);
    fileNameBody += "_" + layerName;
    - sostituirla con:
    var fileNameBody = fileNamePrefix;
    fileNameBody += layerName;
    - cercare la stringa (dovrebbe essere in riga 1047-46)
    var fileNameBody = fileNamePrefix;
    fileNameBody += "_" + zeroSuppress(i, 4) + "s";
    - sostituirla con:
    var fileNameBody = fileNamePrefix;
    fileNameBody += "";
    - salvare e uscire.
    - riavviare Photoshop
    - provare l’azione registrata facendo attenzione che il nome del layer non sia identico al nome di un file già presente altrimenti questo verrà sovrascritto.
    Domanda:
    Perché ho creato livelli che poi ho eliminato ecc.
    Risposta:
    Semplice per evitare errori di esecuzione delle azioni nel caso di operazioni con livelli mancanti o altro.
    Semplice... no?
    English version
    Mac version, but I think it's the same for Windows.
    First of all, I'm translating the actions that I made using the Italian version of Photoshop, you look at the position of the menu that I have chosen to do the work with other languages.
    I explain step by step what I did:
    - I created a sample file with three layers, saved to the desktop and I closed the file.
    - I opened the file and select the layer at the center to start recording an action that I called: Save with Name of the Selected Layer
    - New action
    - Give the name and press Save ( I think it is so in English )
    Now save ...
    - Menu -> Layer - > New —> Layer… and press -ok- , (leave the name that is shown)
    - Once again Menu -> Layer - > New —> Layer… and press -ok- , (leave the name that is shown)
    - Menu -> Layer - > Arrange (order) -> Behind
    - Menu -> Layer - > Merge Down
    - Menu -> Layer - > Merge Visible
    - Menu -> Layer - > New —> Layer… and press -ok- , (leave the name that is shown)
    - Menu -> Layer - Hide Layer
    - Menu - > Delete - > Delete hidden layers (press -Yes- )
    - Menu -> Layer - > New —> Layer… Enter this: ' Move this to the trash ' and press ok
    - Menu -> File - > Scripts -> Export Layers To Files... (In the window that opens select the option you want, but take away the name prefix) and press - Run -
    - Select the History panel and click Delete (on menu opened) pressing -Yes- every time when open the dialog box (8 times Repeat this step until you get into the story to the starting condition. Not use Restore -F12-).
    - Stop recording.
    At this point, by executing this action, I have reached the goal partly because the files created in this way remain, unfortunately, the numerical prefixes to avoid possibly overwriting of files (I think without notice) in the place where they are created.
    To achieve the goal we need a new step and thinking about this as follows:
    WARNING - The operation described below should be made on a copy of the file, so :
    - Duplicate the file
    - Move the original folder to another
    - Work on the duplicate file.
    WARNING - This modification is performed at your own risk and the undersigned assumes no responsibility on what is done mostly by inexperienced hands.
    WARNING - This change will overwrite any files with the same name as the selected layer plus the file extension of course.
    However, the change is trivial and within reach of anyone.
    Proceed as follows:
    - Close Photoshop
    - Open (in the specified path from the image ) file " Export Layers to Files.jsx " (Export Layers To Files.jsx 1.0.0.16) with a pure text editor.
    - Search for the string (should be in line 1029 )
    var = fileNameBody fileNamePrefix ;
    fileNameBody = + "_" + zeroSuppress (i, 4 ) ;
    fileNameBody + = "_ " + layerName ;
    - Replace it with :
    var = fileNameBody fileNamePrefix ;
    fileNameBody + = layerName ;
    - Search for the string (should be in line 1047-46 )
    var = fileNameBody fileNamePrefix ;
    fileNameBody + = "_ " + zeroSuppress (i, 4) + "s" ;
    - Replace it with :
    var = fileNameBody fileNamePrefix ;
    fileNameBody + = "";
    - Save and exit.
    - Restart Photoshop
    - Try the recorded Action, making sure that the layer name is not identical to the name of an existing file otherwise it will be overwritten.
    Question:
    Why I created levels which I then deleted etc..
    Answer:
    Simple to avoid errors of execution of the actions in the case of transactions with missing levels and other.
    Simple ... is not it?
    Sorry for my bad English...
    Thanks in advance for any hint.
    --->>> Please think about this... Adobe <<<---

  • Save to version cue by script

    Hi,
    I want to give it a try and save my documents via script in Version Cue. There are methods like "checkIn" but what is the path to my Version Cue project.
    My Version Cue address is something like "http://10.0.0.1:3703/"
    So my Script needs to use this address somehow, I guess. Has anyone done this before ?
    Thanks Stefan

    Jasker - Thanks you for trying to help, but it didn't work. I followed your directions. Then I attempted to restart the Version Cue server and a Safari browser opened and pointed to http://localhost:3703/ with the message "Safari cant connect to the server.
    Safari cant open the page http://localhost:3703/ because it could not connect to the server localhost."
    I just want it to start up again so I can properly retrieve all of our projects! Even if I can get it back up, I don't think I will use Version Cue the way we used to, now that I know how unreliable it can be.
    Can anyone at least offer advice on how to salvage shared projects (created and maintained by 2 different users) from the Version Cue server when it's offline?

  • How do I save a file with SAVE AS rather than SAVE A VERSION?

    I have entered data on a template file and wish to SAVE AS a named file. Pages gives me only one option "Save a Version" which saves the template file overwritten. What has happened to "SAVE AS"

    Just discovered this "feature" myself and I'll also be filling in a feedback form to point out what an appalling idea this was.  When I read that "Save As..." has been totally removed, can't even be activated as an option, I shook my head.
    "Save As..." has been used in every program I can think of, cross-platform, for decades. It's as fundamental to the user experience as "Open File", "Close Window" or even "Save". It's like Apple deciding on a whim that a little cross is too boring for closing windows, let's make it a swirl instead - except users don't understand what it means.
    My main problem (and maybe someone here can help me with a workaround) is that I often open an old file and tinker with it, then decide I'm making more changes than I thought etc. and it might be better to keep the original and "Save As..." to create a new document. From what I can see, if I hit "Duplicate" I'll end up with 2 files that have my recent changes.  I'll then have to rename the new "Duplicate" file and go back and "Undo" all my recent changes in the original until I'm back to the start (or use "Revert").  Fail to see a way around this and it's such a fundamental problem that will literally hamper my use of Pages on a daily basis, that I'm seriously considering buying Word (what a horrible prospect!).

  • My numbers program created on my mac version 3.0 won't work on my ipad version 2.0. It says I have to save the file with preview option but there is no such option in preferences. Any thoughts?

    my spreadsheet created with numbers program version 3.0 created on my mac won't work on my ipad version 2.0. It says I have to save the file with preview option but there is no such option in preferences. Any thoughts?

    For the update to run Aperture must be installed in the system Application folder and named simply Aperture, not Aperture3.2.2 or anything else.
    I don't know if this would also affect photo stream but if your Aperture is misnamed or installed in an incorrect location fixing that to see if it clears up the problem would be a good first step.

  • Save a version as mp3 with QT Pro7

    I have some 44.1 audio - I would like to use Quicktime Pro 7 to save a version as mp3 but don't see any mp3 export choice....
    I know I can do it in itunes but don't want to
    Q: how do I do it in Quicktime Pro 7?

    I'm pretty sure that QuickTime does not include an MP3 encoder. Your easiest option is probably iTunes. Remember that to get some control over the encode you have to make your encoding choices in the encoding preferences, not at export time.
    Your next best option would be to use LAME (http://lame.sourceforge.net) but that lacks a GUI, so it might be easier to use LAME in conjunction with Audacity (http://audacity.sourceforge.net).

  • Quick Time player cannon be opened because of a problem. Check with developer to make sure Quick Time player works with this version of Mac OS X

    "Quick Time Player cannot be opened because of a problem"  Futher noted - Check with developer to make sure Quick Time player works with this version of Mac OS X.  The player had been working fine on my iMac 24, even after upgrading to Lion. Now, nothing but this message. This involves Quick TIme Player version 10.0. Could upgrading to the 'Pro' version be worthwhile?  Can't find anything on support that comes close to answering this perplexing situation.
    Thanks,

    QuickTime Player 10.0, if that's what you have, is indeed too old for Lion which should have QuickTime Player 10.1. Check your system to see if perhaps you have two copies of QuickTime Player, something quite possible if you moved or renamed QuickTime Player before upgrading.
    Hope this helps.

  • Hello, I was wondering how to get a version of a PDF document? My Adobe shot down and I have not had time to save my document with the notes had been taken. When I reopened there were no notes on my paper. I have a mac book pro. Thx.

    Hello, I was wondering how to get a version of a PDF document? My Adobe shot down and I have not had time to save my document with the notes had been taken. When I reopened there were no notes on my paper. I have a macbook pro. Thx.

    Hi Erika1987,
    If you have not saved the document and Acrobat closed then it's not possible to retrieve the lost data on the pdf file.
    Regards,
    Rave

  • Our version of ID saves all files with the time/date of December 31, 1999.  How do we fix this?

    Our version of ID saves all files with the time/date of December 31, 1999.  How do we fix this?

    That's interesting. The file date should match the system date. What's the system date? What version of InDesign? What operating system?

  • Save in Version set with original

    Brand new to Elements, and I am using Elements 9.   When I have an image open, jpeg, opened in the editor, I would like to check th =e ox saying Save in Version Set with Original, but it doesn't allow me too in the Saving options.  Can anyone tell me why and how I can fix it so I can ?  Thanks in advance !

    Browse and read to know more about the setting. It is almost similar to PSE9.
    http://help.adobe.com/en_US/PhotoshopElements/8.0/Win/Using/WSae2ea3b149d0c3591ae939f10386 0b3d59-7f2e_WIN.html.
    -garry

  • When I adjust the color of a photo with FADE, how do I get it to save that version? the print seems to be the darker version.

    When I adjust a photo using FADE how do I save that version? The print prints out as the darker, original version and I want it lighter.

    Nevermind, I found another example that has this option.

  • Script for Save Options- Save Query Results with document

    Hi,
    Is there any javascript for Save query results with document in save options? If so where can i find that?
    Thanks
    Kalai

    hi guys,
    I found the answer.The following example shows you how to save the results with the query
    section named “SalesQuery”.
    ActiveDocument.Sections["SalesQuery"].SaveResults=true

Maybe you are looking for

  • My external usb mouse no longer works on my dv7-3085dx.

    My HP Pavilion dv7-3085dx, running Windows 7 64-bit, is having issues recognizing the external usb mouse.  Normally the mouse will work a few seconds to minutes before the computer makes the sound that the usb has been unplugged (even thouugh it has

  • WRT400n cant connect wireless to pc

    HI     First time connecting a router ,I installed it made it through all the checks using the advisor,when i clicked go wireless took forever to get the network address and when it said you are connected i unplugged the ehternet cable and lost the c

  • ICC Profile when saving in PSE9

    How do you change the ICC profile when you save a file in PSE9? I need to change the profile to the downloaded version from my photo Lab before they make prints.

  • Anyone else getting a CC subscription reminder though they've already paid?

    I won a free year subscription to the Creative Cloud in 2012. It expires soon, so I called and asked for the Creative Cloud customer rate of 29.99 a month last week and gave my payment information - all was confirmed. Now, my account shows that I hav

  • Installing FCS2

    I am installing FCS2. Leopard is already installed but I also have the first Academic version of Final Cut Studio still. Any advice before I let it rip? Thanks in advance!