How to save a copy of the file? (simple javascript needed)

I'm a noob, so need a Javascript/installation for InDesign CC script, which runs automatically when a file is openand saves a copy of the document to a specific folder, to the present time (i.e. "c:/file/filename_COPY_6_MAY_2014_23_59_59").

This code is just for this work? :

var dmd = app.activeDocument;
var oldDocName = dmd.name;
//make new file
var newDocName = oldDocName.substring(0,oldDocName.length-5); //removes ".indd"
var dd = new Date;
var NewFile = new File("/c/backups_folder/" + newDocName + dd.getDate() + "_" + dd.getMonth() +  "_" + dd.getHours() + "-" + dd.getMinutes() + "-" + dd.getSeconds() +".indd");
//copy
oldDocName.copy(NewFile);









Hi all

I don't think that the link you have provided on stackflow meets your problem and certainly not the best way.

Hopkins response for sure does not seem be correct (sorry)

I think that my script below is the best method.  Don't lead to annoying delays in file open.

Put it in your startup script file

Trevor

// https://forums.adobe.com/message/6363852#6363852
// By Trevor
#targetengine document_copy
(function () {
    if (app.eventListeners.itemByName ("saveCopy").isValid) app.eventListeners.itemByName ("saveCopy").remove(); // makes debugging easier and prevents multiple eventListener creations
    var mySaveCopyEventListener = app.eventListeners.add("afterOpen", saveCopy);
    mySaveCopyEventListener.name = "saveCopy";
}) ();

function saveCopy(ev)  {
    if (ev.target.constructor.name !== 'Document') return;
    saveCopy.Folder = "C:/backups_folder/"; // Change as needed
    if (!Folder (saveCopy.Folder).exists) {
        Folder (saveCopy.Folder).create();
        $.sleep(300);
    }
    if (!ev.fullName.copy (new File (
        saveCopy.Folder + // folder name
        ev.fullName.name.replace(/.[^.]*$/,"") + // file name without suffix
        (" " + new Date).replace (/:/g,"\xB7").replace(/\s\S+$/,"") + // date Change format as desired
        (ev.fullName.name.match(/\..+$/) ? ev.fullName.name.match(/\..+$/).toString() : ".indd") // suffix could be idml or who know what
        ))) alert ("Something messed up, a copy was not made");
}  

Tags: InDesign

Similar Questions

  • EVERYTIME I OPEN A FF OF OUTLOOK E-MAIL WANTS TO SAVE A COPY OF THE FILE IN A TEMPORARY FOLDER, HDI MAKE STOP

    in outlook, click to open a new email. FF opens and a tab appears with a string in a folder:
    file:///C:/users/tymn/APPDATA/local/Temp/%7B3586F5EB-854A-4DA8-B2F7-8C764B716CEA%7d.html

    It seems to be trying to save a copy of the email from outlook to a drive. I do not have this, it's boring. even when I click on the box to not show it, it always does...

    I had the same problem with outlook 2010 and firefox 8.x in WinXP.
    The problem seems to lie between Firefox and outlook.
    Problem only appears when Firefox is the default browser. My vision is not no matter what plugin/add/market.

    Workaround solutions:
    1 use IE as default browser.
    2 backup Firefox BookMark. Then the latest version of Firefox uninstall, delete all settings in the Firefox UN-installing. Turn it back on. Finally, reinstall Firefox and restore the bookmark, and then make as default browser.

    Problem always appear after you apply this workaround solution.

  • Hi, how to do a copy of the os when I need to replace my hard drive?

    My g72, win 7 64 bit, hard drive gives "error hard drive 1 fast access (303)" - bad hard drive.  I'll need OS install when I put in the new HD.  The HD costs about $100.  The operating system has cost another $100.  Other than buying BONE again, I have other options?

    Serial number CNF0372287; Product numberWJ744AV.

    Thank you.

    Did you create a recovery disk set or recovery support? In fact, it's everything you need to recover the PC to the State wherever it was when you bought it.

    Even buying a HP recovery disk or Computersurgeons. should cost only $30.00 USD.

    The activation key for the Microsoft Windows operating system for notebook computer was delivered to you with should be on the bottom of your laptop.

  • How to stop windows 7 from automatically saving a copy of the file to the library?

    I have a desktop hp brand new high.  I installed Microsoft Office 2010.  Whenever I save a file, photo, etc, it saves a copy of the "library".  How it stop doing that?  I read about using the library and he said I could save a copy in the library, but it does it automatically.  Is there a way to stop this?  A I inadvertently set up in this way?  If I delete a file from my documents, it is removed from the library and vice versa.  From what I've read, it should be and the options, not automatic.  If you can help, please dumb it down a lot because I'm not well versed in computer talk.  Thank you very much!

    The library is in fact that index files and in showing them, not actually recording a copy I think. With Explorer open where you can see libraries, choose a category from the left such as the images pane and then right-click and choose Properties. In the window that opens, you should see your C:\ User\Pictures folder that is listed in the index. Click Select, and then click Remove. Now library should not index files. Select each category for example Documents, etc and do the same thing.

  • How can I print a copy of the files in a folder - not each file - just the list

    original title: list of print files

    How can I print a copy of the files in a folder - not each file - just the list? List of cases of printing

    How can I print a copy of the files in a folder - not each file - just the list?

    Karen's directory printer (free)

  • How can I get a copy of the file < windows > \system32\hal.dll.

    How can I get a copy of the file \system32\hal.dll.   ?

    There are 7 possibilities for the hal.dll file and the installation of XP takes the right one to match your hardware during the installation of XP.

    That's why replace a bit difficult because you need to know which of the 7 on the XP installation CD you need.  You can guess and try things and you might get lucky, or you can try them all.  That would take some time and probably be frustrating and you would need a CD bootable XP installation genuine to start the trials and errors.

    Replace the hal.dll file becomes even more difficult, because most of the people do not have a genuine XP bootable installation CD, even if they wanted to replace the hal.dll file.  If you really want just a copy, you can understand that one you need or just copy the one you already have.

    Unfortunately, the Microsoft Answers don't ask for enough information when a new question is asked to provide you with a good idea for your problem not specified.  For all that is your problem not specified, you will need to provide additional information.

    If you see the message that your hal.dll file is missing or damaged, the chances are that the file is not really missing or damaged... Windows XP just can not find the file.

    Fix hal.dll "missing or corrupted" message is usually not too demanding and has nothing to do with the replacement of the file.

    Maybe someday the dialog box 'ask a question' forums XP will ask these questions automatically when a new thread is started so I don't have to ask every time.  It might even be possible to solve a problem in a single response when enough information is provided.

    Please provide additional information on your system:

    What is your system brand and model?

    What is your Version of XP and the Service Pack?

    Describe your current antivirus and software anti malware situation: McAfee, Symantec, Norton, Spybot, AVG, Avira!, MSE, Panda, Trend Micro, CA, Defender, ZoneAlarm, PC Tools, Comodo, etc..

    The question was preceded by a loss of power, aborted reboot or abnormal termination?  (this includes the plug pulling, buttons power, remove the battery, etc.)

    The afflicted system has a CD/DVD drive work?

    You have a true bootable XP installation CD (it is not the same as any recovery CD provided with your system)?

    What you see you don't think you need to see?

    What do not you think that you should see?

    If the system works, what do you think might have changed since the last time it did not work properly?

  • Windows media player does not automatically open a video file on a Web site but I save it and open the file with Windows media player to play the video or audio recording.

    Windows media player does not automatically open a video file on a Web site but I save it and open the file with Windows media player to play the video or audio recording. I used to be able to play any video or audio file in any site!

    Hello

    Try resetting the default associations for WMP and IE.

    How to set default Associations for a program under Vista
    http://www.Vistax64.com/tutorials/83196-default-programs-program-default-associations.html
    How to associate a file Type of Extension to a program under Vista
    http://www.Vistax64.com/tutorials/69758-default-programs.html

    If necessary:

    How Unassociate a Type of Extension file in Vista - and a utility to help
    http://www.Vistax64.com/tutorials/91920-unassociate-file-extention-type.html
    Restore the Type Associations by default Vista file extensions
    http://www.Vistax64.com/tutorials/233243-default-file-type-associations-restore.html
    How to view and change an Extension of filename on Vista
    http://www.Vistax64.com/tutorials/103171-file-name-extension.html

    ====================================

    Also follow these steps:

    Follow these steps to remove corruption and missing/damaged file system repair or replacement.

    Run DiskCleanup - start - all programs - Accessories - System Tools - Disk Cleanup

    Start - type in the search box - find command top - RIGHT CLICK – RUN AS ADMIN

    sfc/scannow

    How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe) program
    generates in Windows Vista cbs.log
    http://support.Microsoft.com/kb/928228

    Then, run checkdisk - schedule it to run at next boot, then apply OK your way out, then restart.

    How to run the check disk at startup in Vista
    http://www.Vistax64.com/tutorials/67612-check-disk-Chkdsk.html

    ------------------------------------------------------------

    Then, if necessary:

    Have you recently installed another player?

    Reset your associations for WMP and IE.

    How to set default Associations for a program under Vista
    http://www.Vistax64.com/tutorials/83196-default-programs-program-default-associations.html
    How to associate a file Type of Extension to a program under Vista
    http://www.Vistax64.com/tutorials/69758-default-programs.html

    ---------------------------------------------

    Do this to reregister the Jscript.dll and Vbscript.dll files.

    Start - type in the search box - find command top - RIGHT CLICK – RUN AS ADMIN

    type or copy and paste-> regsvr32 jscript.dll
    Press enter

    type or copy and paste-> regsvr32 vbscript.dll
    Press enter

    Restart and if all goes well, it will run now.

    --------------------------------------------------------------

    Have you recently added stores or ANY application from Stardock?

    Using 64-bit Vista?

    Can you think of recent things you did in WMP which could be the cause? You added another
    reader recently or an add-on for WMP?

    When I try to use Windows Media Player 11, the program does not start, or some UI elements
    are empty - a Mr Fixit
    http://support.Microsoft.com/kb/925704/en-us

    Maybe something here
    http://msmvps.com/blogs/chrisl/articles/17315.aspx
    and here
    http://msmvps.com/blogs/chrisl/Archive/2004/10/30/17399.aspx

    Check here the news of WMP11
    http://zachd.com/PSS/PSS.html

    I hope this helps.

    I hope this helps.

    Rob - bicycle - Mark Twain said it is good.

  • All my tabs are missing! Rename and copy/paste the files did not help

    I accidentally opened two windows of Firefox and closed one with all my tabs pinned first, then the second tab. After Firefox reload all my tabs are missing and I tried to rename files, copy and paste files, etc. as suggests these forums, but nothing has worked. I have myself screwed on?

    Check first the Menu history for any tab restore options.
    In the second place.
    If you have already restarted Firefox and have a copy of the files: close Firefox

    1. Open the profile folder profiles - where Firefox stores your bookmarks, passwords and other user data
    2. Save the previous.js recovery.bak and recovery.js under another name
    3. Place the recovery files in the profile folder.

    So that this does not happen again change your tab Preferences and settings or try Session Manager add and save your profile.

  • How to save a copy of Windows XP that has been created by an image?

    I used 'Image for Linux' to create an image of a PC with Windows XP, SP3.  With that done, I can copy the image to a new PC and it works fine (assuming that I stay within the limits of the PC HAL).

    My problem is that I don't have to enter a new key of Windows XP when I installed the image on another PC. for example, I use a license of Windows XP on two PCs.  Since I want to be legitimate on my software license, I tried to activate Windows XP license to new PC - but the computer says that the license is already activated.  So it is logical that the new PC would react like that - I put the picture of an activated copy of Windows on a new PC, the new copy of Windows must also think that it is enabled.

    All this brings me to my original question: how to save a copy of Windows XP that has been created by an image?

    Hi RichardMatt,
     
    I recommend you contact the customer service of Microsoft for queries on activation for clarity.
     
    See the following article to do the same thing:
  • Save a copy of the emails opened on the Server POP3 format

    I have POP3 format on windows email. I want to save a copy of the emails opened on the server, so I can access it later from a distance (with my phone). How can I do this?   Thanks in advance.

    I have POP3 format on windows email. I want to save a copy of the emails opened on the server, so I can access it later from a distance (with my phone). How can I do this?   Thanks in advance.

    Open Windows mail > tools > accounts > click your account > properties > Advanced tab > under delivery, check ' leave a copy of messages on the server ' > OK for the benefits of others looking for answers, please mark as answer suggestion if it solves your problem.

  • How to save an email to a file to my hard drive?

    Save Email on hard drive

    I have Windows 7 and I am confused with the new XP system.  I now get all the answers to my email to an email and sometimes do not know that I got a new email.  They all stay together.   The other question I have is how to save an email to a file to my hard drive.  I would like to save emails in my folders related discipline.  Appreciate any help

    You use Windows Live Mail?  If so, it seems that you have enabled the
    option of aggregates by "Conversation".
    On the view tab, click Conversations, Off.
     
    To save a message to your hard drive, click the icon without label to the left
    of the House, then save, save as a file.
     
    --
    Gary van, Microsoft MVP
    ------------------------------------------------
    "RickSplaine" wrote in message
    News: * e-mail address is removed from the privacy... *
    > I have Windows 7 and I am confused with the new XP system.  I now get
    > answers to my e-mail for a message and sometimes do not know that
    > I had a new email.  They all stay together.   The other issue I have is
    > How can I save an email to a file on my hard drive.  I would like to save
    > emails in my folders-related subjects.  Appreciate any help
     
     

    Gary van, Microsoft MVP (Mail)

  • RMAN-06024: no backup or copy of the file of control found to restore

    I have installed oracle 11.2 on virtual machine and made two copy of this vm i.e vm1 and vm2

    I took the backup with rman vm1 and automatic backup of the control file.


    Now I want to restore this backup on vm2, I configured for this channel and other settings.

    running following command

    Catalogue start with "\\server3\database_backup\rman\C-3507808503-20130531-00";

    "C 3507808503-20130531-00" is the name of the control file backup.


    RESTORE CONTROLFILE;

    It gives me error

    RMAN-06496: must use the TO clause when the database is mounted or open

    can I use after a command

    RESTORE CONTROLFILE to 'C:\oracle\Administrator\oradata\slate ';

    then it gives me error
    RMAN-06024: no backup or copy of the file of control found to restore

    can someone help me how to restore the control for vm2 file

    Hello

    909855 wrote:
    I have installed oracle 11.2 on virtual machine and made two copy of this vm i.e vm1 and vm2

    I took the backup with rman vm1 and automatic backup of the control file.

    Now I want to restore this backup on vm2, I configured for this channel and other settings.

    running following command

    Catalogue start with "\\server3\database_backup\rman\C-3507808503-20130531-00";

    "C 3507808503-20130531-00" is the name of the control file backup.
    RESTORE CONTROLFILE;

    It gives me error

    RMAN-06496: must use the TO clause when the database is mounted or open

    can I use after a command

    RESTORE CONTROLFILE to 'C:\oracle\Administrator\oradata\slate ';

    then it gives me error
    RMAN-06024: no backup or copy of the file of control found to restore

    can someone help me how to restore the control for vm2 file

    Why use the network path?

    Copy all the files backup on VM2 for example C:\Backup folder and try

     set DBID ...
     restore controlfile from 'C:\Backup\C-3507808503-20130531-00';
     alter database mount;
     catalog start  with 'C:\bakup';
     restore database;
    

    If you are using same directories for databases on VM1 and VM2, not catalog must start with command.
    Because RMAN Catalog backup VM1 information in the control of catalog file repository.

    Concerning
    Mr. Mahir Quluzade

  • I'm trying to move a song to my iPhone music library to the iTunes library on my MacBook Air.  I do not want to synchronize the two, so how do I simply copy/migrate the song on my computer?

    I'm trying to move a song to my iPhone music library to the iTunes library on my MacBook Air.  I do not want to synchronize the two (and they have never been synchronized), so how can I simply copy/migrate the song on my computer?  Is there a way to do, without having to re-purchase the song on the iTunes Store on my Mac?

    E-mail (for yourself) click on it in the email

  • In the Finder, how can I search/list of the files in the folder of final characters in filenames, i.e. 'to end-with' alphabetical rather than by default "starting by" alphabetical?

    In the Finder, how can I search/list of the files in the folder of final characters in filenames, i.e. 'to end-with' alphabetical rather than by default "starting by" alphabetical?

    As far as I know, you can't.

  • the friends hyii UA HUD need help how to make a backup of the files from his deleted with (shift + delete) memory card

    the friends hyii UA HUD need help how to make a backup of the files from his deleted with (shift + delete) memory card

    Hello

    It seems that you want to restore the files removed from the memory card.

    I will definitely help you with this.

    I would say you can search the Internet for data recovery software by using your favorite search engine.

    Warning: Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

    It will be useful. If you have any other questions, feel free to let us know. We will be happy to help you.

    Thank you.

Maybe you are looking for