Rename the opening file & then open it

Hi,
I am looking for a script which can -
1. On opening a file rename it. For e.g. Rename "FileName1.indd" to "FileName1-in-use.indd"
2. Then open the file "FileName1-in-use.indd"
3. Then on closing rename it back to "Filename1.indd"
Is it possible?
Regards

Hi there
I am not sure if this meets your needs. What about «race conditions»?
Give this a try.
Kind regards
Daniel (from Switzerland)
main();
exit();
function main() {
    var myDoc = File.openDialog ("InDesign-File", fileMaskINDD);
    if (myDoc != null) {
        // get the actual filename
        myFileName = myDoc.name.substr(0, myDoc.name.indexOf("."));
        myNewFileName= myFileName.replace(myFileName, myFileName+"-in-use.indd");
        // rename the actual doc
        myDoc.rename(myNewFileName);
        // open the InDesign document
        tempDoc = app.open(myDoc);
        // do your stuff here
        do_your_stuff_here(tempDoc);
        // save and close
        tempDoc.save();
        tempDoc.close();
        // rename the document again
        myDoc.rename(myFileName+ ".indd");
        alert("I did my job, what about yours?");
function do_your_stuff_here(myDoc) {
    alert("Do your stuff here");
    To filter the files and only show InDesign files or directories
function fileMaskINDD(myFile) {
  if (myFile.constructor.name == "Folder") { return true }
  if (myFile.name.slice(-5) == ".indd") { return true }
  return false;

Similar Messages

  • Error opening file, then opens

    Frequently, when I click on a file to open it I get the error message below.  It may be from any app - CAD, iWorks, OpenOffice, iPhoto.  Sometimes I am inside the app, such as Keynote  and use Open Recent Files, such as the example in the picture.
    When I click on the file the second time, it usually opens.  Sometimes the app opens, but not the file (blank screen).  Another Open command then works.  This has happend on the original motherboard and a brand new replacement board (same HD).

    The reason I assumed, or asked, whether it was Windows-only is because of your use of the backslash character as the folder delimiter. To make the script cross-platform try the following:
    on mouseUp me
      acro = baFindApp("pdf")
      if ( acro = EMPTY ) then
        alert "This program was unable to find a suitable program on your system to open a PDF document. It will open www.adobe.com, where you can download a free viewer"
        goToNetPage "http://www.adobe.com"
      else
        mPath = _movie.path
        tFile = mPath & "Resource" & mPath.char[length(mPath)] & me.pPDF
        if baFileExists(tFile) then
          OK = baOpenFile(tFile, "normal")
          if ( OK < 32 ) then
            -- see docs for numbers and their meaning
            alert "Error opening file:" && OK
          end if
        else
          alert "File not found:" &RETURN& tFile
        end if
      end if
    end

  • In the Menu Bar, under File, then Open File, how do I change the selections?

    I have Firefox 11.0 and Windows 5.1 (2007). In Firefox, I click on FILE in the Menu Bar, then OPEN FILE (Ctrl+O), and I see a small box; it says Look in: Mozilla Firefox. Below is a selection of files within the folder Mozilla Firefox. To the left is a column of four other folders: Downloads, My Computer, John, Lori. The last two are obviously two of the folders I've created on my computer, using Windows. But I don't know how they got here! I have no recollection of customizing this particular Firefox menu option by adding those folders, nor can I figure out what to do in order to further customize it. Can anyone tell me: (1) how can I change the original "Look in" option so that it opens with something other than "Mozilla Firefox" (which, after all, I never need to access)? (2) how can I add/delete/change the choices offered in the column on the left, so that different folders are listed? (Currently, if I want to access my Windows folders/files, I first have to minimize the Firefox screen; this seems to me a nice shortcut, but I'd like it to include shortcuts to the folders I use the most, which does not include "Mozilla Firefox"!) (3) Is this actually a Firefox feature, or is it a Windows feature? It does look like Windows (Windows style, Windows folders), but it appears only in the Firefox Menu Bar, along with Bookmarks, Tools, etc. Thanks!

    This sounds like a Windows thing ( You can post a photo and I can tell you for certain). Those folders are Windows system created folders that your computer has had since it was installed, all Firefox does is use the Windows File picker, which is what you see when you open that window. So, to customize you'd have to do that from Windows Explorer (not Firefox).
    The Window should however remember what folder you were in last.

  • File Error: The Specified file is open and in use by this or another app...

    I have imported a string of pictures and dragged them into the FCP timeline. I render them and it renders a certain percentage then it stops and says "File Error: The Specified file is open and in use by this or another application."
    After reading this, I quit out of FCP, restarted my computer, opened FCP, nothing other program, tried to render again and same thing happened. It renders part of it then the error message pops up, then I can render again and it will do another percent then it will pop again and so on.
    Suggestions, or does anyone know why this happened? Thank you very much for your time.
    A

    okay - don't know where you've got your scratch disc set but hopefully it's to another drive other than your boot.
    The same drive where your render files should be located, ie some drive other than your boot drive.
    Can you copy the jpegs over to that drive into a folder.
    Delete them from your tl, delete them from your proj. Save your project. Close fcp.
    If they're on your boot drive - delete them.
    Reopen fcp and Reimport them from the new location.
    Sorry for all the steps - but we have no idea how you have configured fcp or your level of experience. Trying to cover all the bases ...

  • TS1702 Re: Notes App. I opened Notes, then opened a particular note. It opened briefly, and then suddenly several notes, from the past two weeks, just disappeared. Is this a known glitch, and is there any way to retrieve or restore these lost notes?

    Re: Notes App. I opened Notes, then opened a particular note. It opened briefly, and then suddenly several notes, from the past two weeks, just disappeared. Is this a known glitch, and is there any way to retrieve or restore these lost notes?

    The other day i deleted my email accounts off of my ipod and only reloaded a few of them. today i looked at my notes to look at a project i had typed on my notes because i didnt have paper and pen around to write it and i didnt want to froget. I reloaded the rest of my emails in hope that everything would reappear but sadly only some of them from 2010 loaded. Recently i had update some of the files and they were like they were when i first created them there were alos ones that i had deleted long ago. There are other notes i had made that were really important to me to andi wouldn't be able to remember every single one. Help Please!

  • ICal failing to run applescripts: The 'Open' button does not change to 'Run', and the script file is opened but not executed on alert.

    iCal failing to run applescripts: The 'Open' button does not change to 'Run', and the script file is opened but not executed.

    Calendar (not called iCal anymore) does not include that capability any longer, apparently.  What you have to do now is go to Automator and create a Calendar Alert action.  You can add a Run AppleScript object to the action and paste in your script there, then when you save it, it will become available as a choice in the alert menu in Calendar.

  • I get a message - Adobe can't download a PDF with this browser - download by your browser and the try to then open the PDF open the PDF

    I am using Firefox 17.0.1 for the MAC - I have no idea about how I would go about downloading the information to then open the PDF
    This is a new problem because in the past I have been able to open PDF's and I can open saved PDF's

    Check your Plugin
    *https://www.mozilla.org/en-US/plugincheck
    Make use of Adobe Reader to View and Download PDF.
    *https://support.mozilla.org/en-US/kb/use-adobe-reader-plugin-view-or-download-pdf-files
    Otherwise, Make use of FOXIT Reader.
    *http://www.foxitsoftware.com/downloads/
    *http://www.foxitsoftware.com/Secure_PDF_Reader/addons.php

  • In CS5, Win7...go to File, then Open...do you see .PSD thumbnails with preview images?

    In CS5, Win7...go to File, then Open...do you see .PSD thumbnails with preview images?
    In all other versions of Photoshop, I can see a preview of the image, even .psd files, but with CS5 now, I just see the PSD icons...this again, is when you go to File, then Open...  Anyone else see this?  In Elements 9, I see the preview thumbnail icon, not generic, same with CS3 and Elements 7, but not with CS5? 

    Well, I was thinking if others tried on their Win7 system, they could let me know if they get the same result or different...so by comparison I could see if I had an issue with my software, such as if it were standard...  However, I did figure it out...  It's a 32-bit vs. 64-bit difference.  Elements 9 is a 32-bit software, and so is CS5 32-bit of course....so both of those softwares show .psd thumbnails in the File, Open view...but the 64-bit does not...in Win7 64-bit...in case anyone else is wondering...  

  • When i try to open week cal it loads and then closes after a few seconds...I have checked for updates, turned the phone off then on, closed out of the app and then opened it again...nothing works!  Any suggestions?

    When i try to open week cal it loads and then closes after a few seconds...I have checked for updates, turned the phone off then on, closed out of the app and then opened it again...nothing works!  I have thought about deleting the app from my phone and then reloading it again but I worry that it will delete all my calendar info???  Any suggestions?

    To reset, press and hold the Home and power buttons until the silver apple appears.
    I would delete the app, reset the phone and then download the app again. Your calendar information should be stored on the phone as Week Cal uses the Calendar app information.
    Best of luck.

  • FILE ERROR: The Specified file is open and in use...

    FILE ERROR: The Specified file is open and in use by this or another application.
    I get this error when I import a .MOV created by Live Type. All applications, except FCP, are closed. I can reboot the computer and get the same thing. It happens when I try and "render all". Thanks.

    It's probably either spotlight looking at the files, or some anti-virus program thinking your render is a virus.

  • Adobe reader will not open pdf files I have saved as, or, export as pdf to my desktop (latest Maverick). The same file does open when I am on the source website (i.e. user manuals etc.). Why?

    Adobe reader will not open pdf files I have saved as, or, export as pdf to my desktop (latest Maverick). The same file does open when I am on the source website (i.e. user manuals etc.). Why?

    iMac G4, Mac OS X (10.4.9)
    Make sure you have the latest Adobe Reader installed for your OS.
    http://www.adobe.com/support/downloads/product.jsp?platform=macintosh&product=10
    Did you try using Preview. If you control click on the PDF on your desktop you can use the "open with" option.

  • I am trying to link coc between a new ipod and my iPad. The iPad was the old device. I did as I was supposed to by logging in the Game Center, then opening coc, and went thru the tutorial. The Game Center keeps trying to load the new village on my iPad an

    I am trying to link coc between a new ipod and my iPad. The iPad was the old device. I did as I was supposed to by logging in the Game Center, then opening coc, and went thru the tutorial. The Game Center keeps trying to load the new village on my iPad and not the other way around. It basically is trying to make my old village the new village, meaning I lose a lot of progress. How do make it combine the 2? If I cannot, is there a way to remove the new village off the Game Center and add the one I want to be saved? Thank you.

    You'll have to contact the app developer for help with this.

  • Just downloaded latest updates to Camera Raw for use with my new Sony RX100 M3 but still can't get the RAW files to open. Any suggestions?

    Just downloaded latest updates to Camera Raw for use with my new Sony RX100 M3 but still can't get the RAW files to open. Any suggestions?

    Never mind, I finally got it working, thanks!

  • How to know if the pdf file is opened.

    Hi,
    on my web site I have many pages containing hundrend of url pointing to the pdf documents.
    The problem is how I can know that the pdf file was open or downloaded by user ( I used session for this task). I have to point out that I did not integrate in my page any javascript action on those documents.
    This point will help me to solve some historical access on the web site.
    Thank you

    Your best bet would be to create a filter that will handle access to pdf files. This filter would be bound to /*.pdf and can have access to the users HttpSession object so you are able to find out who requested this file and logic it how ever you wish.
    I Hope this helps
    -Richard Burton

  • I'm trying to export a raw image from lightroom 5.6 to Photoshop cc 2014 2.1.  I right click to export menu in lightroom as I've always done to export to Photoshop.  Photoshop opens, but it can't open file, window opens to find a file to open.  I'd like t

    I'm trying to export a raw image from lightroom 5.6 to Photoshop cc 2014 2.1.  I right click to export menu in lightroom as I've always done to export to Photoshop.  Photoshop opens, but it can't open file, window opens to find a file to open.  I'd like this to export my lightroom images to edit in photoshop as it has always been able to do for me.  What fix do you recommend?

    Hi Ashley Clavette,
    The Initial view setting works perfectly when the file is opened in Acrobat after setting the desired Initial View.
    When you upload the file onto Wordpress, and view it on that website in the browser...it might be using a different pdf handler program which might be causing this issue ( it would be helpful, if you could provide the screenshot) , however when you download the pdf again from wordpress server...and open in Acrobat/Reader...then what  exactly happens ?  Does the pdf opens in the desired Initial View setting?
    Rahul

Maybe you are looking for

  • "No direct posting can be made to G/L account 140000 in cocode GBTS

    hello gurus  below is the problem i asked earlier iam creating PO with account assignment category 'K' . I have been cncountered with a probklem "No direct posting can be made to G/L account 140000 in cocode GBTS Diagnosis G/L account entered is a co

  • Photoshop CS6 can't/won't open TIFF file created in photoshop CS3

    Earlier this year, I was still using CS3. I created a bunch of original TIFF files, and modified files which had been created in CS1. When I am having to go back and reference these CS3 TIFFs, some of them are giving me an error message and refusing

  • 8.10.01 Installed, not stamped correctly

    After installing the 8.00c.10.01 fix, I checked the engine version and it still says 8.00c.10.00.  Is the posted patch correct and it is just a labeling problem?  Thanks, dvn

  • How to run the exemple client program in win98

    HI I have installed weblogic server5.1 in windows 98 and while i try to run my client program from dos prompt it is not working. i am calling my from the same m/c where i installed weblogic server like this: This program is given in the weblogic exam

  • Can't update Premiere Pro CC

    Hi, Premiere Pro CC won't update any more, returning error U44M1P7 Windows 7 x64 is fully up to date, as is the CC desktop app. Please help!