Applescript: file.open("r") returns empty in jsx

Hey guys,
i am having a bit of a scripting problem here. The big goal for me at the moment is creating a UI script to control aerender.
To achieve getting feedback from the terminal about when an aerender process is completed, i let the terminal trigger an applescript running a jsx inside after effects (since the terminal can't run a jsx inside after effects itself).
However, this particular script needs to eval the contents of a text file that is outputted during the render process (its just a log file put into a fixed location). No matter what i do: I can't get a proper response from the script. Here is what should happen when a render is done:
function RenderEnd () {
var report = new File ("Macintosh HD/Users/macname/generallog.txt");
report.open("r");
var reportstring = report.read();
report.close();
var reportendindex = reportstring.indexOf("Total Time Elapsed:");
var reportcloseindex = reportstring.indexOf("aerender version");
var reportendstring = reportstring.substring(reportendindex, [reportcloseindex]);
var regex = /Finished composition/gi, result, indices = [];
while ( (result = regex.exec(reportstring)) ) {
    indices.push(result.index);
var ItemStringArray = new Array ();
for(var i=0; i<indices.length; i++){
    ItemStringArray.push("Finished Item " + (i+1) + ": " + reportstring.substring(indices[i]-32, [indices[i]-2]));
var AlertString = "Rendering done." + "\r" + reportendstring + "\r" + ItemStringArray.toString().replace(",","\r");
alert(AlertString);
RenderEnd ();
Running this script by itself properly returns an alert containing a message "Rendering done." plus additional info about the render time and item completion.
But whenever i have the following applescript triggering the above jsx script...
set scriptfile to (POSIX file ("/Applications/Adobe After Effects CS5.5/Scripts/AERenderEndTrigger.jsx"))
tell application "Adobe After Effects CS5.5"
  DoScriptFile scriptfile
end tell
...the line report.open("r") just returns empty.
Same goes when i place the jsx in the startup folder and just call the function RenderEnd () via applescript. It's as if the file open/read stuff does not work when using applescript.
Does anybody have an idea about this or knows the reason for why this obviously wrong behaviour happens? Maybe someone knows a different approach of how to get feedback from a completed aerender process back into a UI script.

Ok, i finally found the issue:
Applescript apparently does not recognize file paths beginning with a drive designation:
When i change the file path part of the report file from
var report = new File ("Macintosh HD/Users/macname/generallog.txt");
to simply
var report = new File ("/Users/macname/generallog.txt");
everything works as it should.
It's still a bit weird and i don't understand this. Maybe someone can explain this to me, please?

Similar Messages

  • Garageband files open with 2 empty tracks?

    i am using logic pro x and garageband band x..
    16gb ram, 250gb ssd with yosemite os x.x
    i am trying to "open" garageband files in logic pro
    when i do this, logic prompts me to "save" the file as logic project file and i do so
    however,
    the contents of the file are not opened, and i only get 2 tracks which are both empty in LP.
    Audio Recorder
    Output
    what seems to be the problem?
    from the aditional downloads section, i downloaded the compatibility stuff -
    do i have to install EVERTHING??
    how do i fix this?    

    Hey,  there's no one from Apple here, we're just users like yourselves, if no one knows a fix you won't get a reply. It's probably best to call Apple's support line.

  • Applescript: File remains "open" even if trashed and gone

    re: simple text file written in AS alone, outside Finder:
    1. I write to a file like this:
      set thisFile to open for access aFilePath with write permission
      — do stuff
      close access thisFile
    As long as "do stuff" executes OK., the close access is hit and I can use the file over and over. I have no problems with this script. But:
    2. If “do stuff” hits an error, it leaves me with an unusable file. Even when the file is trashed and gone (Secure Empty Trash), if I ever try to use the same file name, AS will first create the file, but immediately pop an error that that file is already open before I can do anything else. The system is remembering the file name and flagging it as open (apparently).
    3. So I try to close it:
          set thisFile to file aFilePath
          close access thisFile
    and I get no error on the first line but a  “ ... [correct path to "thisFile"] cannot be made into type file" error on the second line.
    Question 1: If "thisFile" is a file on the first line, then why not on the second? Why does "close access" which works in item 1 above, fail here?
    So any new file name works as long as "doStuff" works, but I can't use any file name that didn't close the first time through. I cannot seem to close the file after the fact, even when it's been trashed.
    Question 2: how do I tell the system that this file is not open or does not exist?
    Great thanks for your help!

    I'm guessing that this is happening to you while running the script in the script editor.
    When a script is run in the editor it is the editor that actually has the file open and if the script exits without closing the file the editor gets hung.  Any open files are automatically closed when the application exits but as it is the editor that has the file open the file is not closed when the script exits only when the editor exits. So one work around is to close the editor and restart it.
    However the correct way to handle this is to the file work in a try on error block. See Introduction to AppleScript Language Guide specifically the section Close access, the command used to close an open file, for more details.
    The basic idea
    set aFile to choose file
    set fp to open for access aFile
    try
      --file reading and writing here
    on error e number n
      --deal with errors here and don't resignal
    end try
    close access fp

  • Run applescript automatically on file open and close

    Is it possible to automatically invoke a given applescript when opening -any- document with a given application?
    In effect, I would like to automatically detect the "open file" operation (irrespective of how the file was opened) so as to immediately follow it with a specific AS.
    I would similarly like to automatically invoke another AS prior to a "close file" operation.
    Is this possible via Automator or some other way?
    Thanks,
    humanengr

    try restart
    http://support.apple.com/kb/HT1430

  • Applescript to open multiple files

    I have worked up 2 applescripts
    1. to open a set of files
    2. to position the individual windows ( finder and application)
    The first script does not open all the 4 files at one proces, it should.
    In applescript the first run, opens 2 or 3 of the 4, a second Run will open the remaining, or a 3rd run may be required, to get all 4 files open
    Same with the Applescript saved as an application
    Applscript as per:
    tell application "Finder"
      activate
              set PTH to POSIX path of (path to home folder) & "Documents/p1/client/P079/aaa"
      do shell script "open " & PTH
              set bounds of Finder window 1 to {273, 569, 550, 1100}
              set position of Finder window 1 to {6, 44}
    end tell
    tell application "Finder"
      activate
              set PTH to POSIX path of (path to home folder) & "Documents/p1/client/P079/folder_a/data_a.fp7"
      do shell script "open " & PTH
    end tell
    tell application "Finder"
      activate
              set PTH to POSIX path of (path to home folder) & "Documents/p1/client/P079/folder_b/data_b.fp7"
      do shell script "open " & PTH
    end tell
    tell application "Finder"
      activate
              set PTH to POSIX path of (path to home folder) & "Documents/p1/Office/cs_time/Time_v4/a_user_time.fp7"
      do shell script "open " & PTH
    end tell

    Spoke too soon, its still irregular.
    still requires repeating the Applescript Run to open all 4 ( 1 folder 3 files)
    Something weird with the files. I created a new generic folder and subfolders and files named as below, and this runs fine, all 4 every time. But the real project files, 3 out of four first on first run, and the 4th on the second run.
    I makes a difference too, wrt to the order; changing the folder to the last execution only opens 2 targets on the first run, then the 3rd in the second run, the 4th on the 3rd run... and other variations. Feels like some sort of reset or flush to something is required.
    I tried targetting a different file(s) and same mixed results
    It is not a typo in the paths, subsequent runs open the files
    this with test files/folders as define works every time
    set basePath to POSIX path of (path to home folder) & "Documents/p1/"
    set officePath to basePath & "_CS_Office/cs_time/Time_v4/a_user_time.fp7"
    set clientPath to basePath & "FileMaker/_activeProjects/Client/P079/"
    set DR1 to "aaa"
    set FA to "folder_a/data_a.fp7"
    set FB to "folder_b/data_b.fp7"
    do shell script "open " & clientPath & DR1
    tell application "Finder"
              set bounds of Finder window 1 to {273, 569, 550, 1100}
              set position of Finder window 1 to {6, 44}
    end tell
    do shell script "open " & clientPath & FA
    do shell script "open " & clientPath & FB
    do shell script "open " & officePath

  • 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.

  • When I have a pdf file open, I used to be able to click on "Bookmarks" tab on left side and allow me to click on each individual page and delete if I needed to.  Now when I click on the Bookmarks tab, that section is empty.  How can I get it to show each

    when I have a pdf file open, I used to be able to click on "Bookmarks" tab on left side and allow me to click on each individual page and delete if I needed to.  Now when I click on the Bookmarks tab, that section is empty.  How can I get it to show each page again?

    Hi chrismarks1,
    I think you may be confusing bookmarks with thumbnails. If you click the Page Thumbnails icon (the one above the Bookmarks icon), then you can delete a page by clicking its thumbnail, and clicking the Delete Pages icon (the trashcan icon). Just make sure that you're viewing the PDF file in Acrobat (rather than Acrobat Reader), as you can't delete pages from Reader.
    Best,
    Sara

  • When I open up an e-mail attachment a box pops up PRINT TO FILE below that line OUTPUT FILE NAME with an empty line for the file name vs. simply going to my default printer?

    when I open up an e-mail attachment a box pops up PRINT TO FILE below that line OUTPUT FILE NAME with an empty line for the file name vs. simply going to my default printer?

    Make sure that '''''Print to File''''' isn't selected in the native print dialog box ''(see screenshot below)'' middle-right, and make sure your Printer is selected at the top of that dialog box.
    ''I'm a little confused why an email attachment would need to go directly to the printer, but that's what you asked about.''

  • Applescript photoshop open file delay

    Hi,
    I have a problem with photoshop and applescript. When I run the following simple applescript which opens a document and saves it in a location:
    tell application "Adobe Photoshop CS3"
    open picpathalias
    -- delay 10 -- quite a long delay is needed
    save current document in file regpicpath as JPEG
    end tell
    I often receive the following error:
    Adobe Photoshop CS3 got an error: General Photoshop error occurred. This functionality may not be available in this version of Photoshop.
    - The object current document is not currently available.
    It seems there is a race between the open cmd and the save cmd. This most often happens when photoshop is not yet an open application. It almost never happens when photoshop is already open. Is there a programmatic way to make open block until the document is available?
    Thanks.
    -yang

    To clarify, I would like to avoid a soln that uses an arbitrary timeout delay if possible.

  • PSCS3 Mac: Can't get Applescript to open "desktop:folder:file.jpg"

    I have Photoshop CS3 and am scripting a lengthy workflow, and part of it requires that I get Metadata out of files using Photoshop.
    I can not get Photoshop to open a file. Once I have the file open, I can get the metadata out using UI scripting, but I have tried numerous approaches to open files and it has me stumped.
    I am making it as a function that I can call from the main script which compares a new list of files with a list that is a few minutes old to determine which files are new and repeats with each file in the list. So the function will be getting a file name or a path.
    Any help would be greatly appreciated!
    Brian

    I got it! It needs to be an alias class path, and I had to concatenate the path incrementally before finally the whole path is in one variable I could coerce into an alias.
    Of course, this is just one segment of the whole workflow.
    tell application "Finder"
    activate
    set fileList to name of (items of folder "to gallery" of desktop)
    repeat
    set newFileList to name of (items of folder "to gallery" of desktop)
    if length of newFileList > 0 then
    repeat with thisFile in newFileList
    if thisFile is in fileList then
    else
    my PSInfoGalAdd(thisFile)
    end if
    end repeat
    set fileList to newFileList
    end if
    delay 30 --This will eventually be 4 minutes
    end repeat
    end tell
    on PSInfoGalAdd(thisFile)
    tell application "Adobe Photoshop CS3"
    activate
    set desktopPath to path to desktop
    set toGalPath to desktopPath & "to gallery:" as string
    set wholePath to toGalPath & thisFile
    set openIt to wholePath as alias
    open openIt
    tell application "System Events"
    tell process "Adobe Photoshop CS3"
    key code 34 using {command down, option down, shift down} --File info window
    delay 4
    repeat 12 times
    key code 125 --down arrow to Origin
    delay 0.2
    end repeat
    repeat 5 times
    key code 48 --tab to credit
    delay 0.2
    end repeat
    key code 8 using command down --copy
    delay 0.3
    set credit to the clipboard
    repeat 3 times
    key code 48 --tab to instructions
    delay 0.2
    end repeat
    key code 0 using command down --select all
    delay 0.3
    key code 8 using command down --copy
    delay 0.3
    set headline to the clipboard
    key code 48 --tab to transmission reference
    key code 0 using command down --select all
    delay 0.3
    key code 8 using command down --copy
    delay 0.3
    set body to the clipboard
    key code 48 --tab
    key code 36 --return key to dismiss info window
    end tell
    end tell
    end tell
    end PSInfoGalAdd

  • I can't open my mail unless I use the Enter/Return key or go to the File -Open Message

    Up until yesterday I could open an email just by double clicking the message. Now if I want to open a message I have to use the Enter/Return key or go into FILE and press Open Message.
    The only thing different since yesterday morning is that I decided to turn off File Vault --that process took all day but finally finished and that's when I ran into problems with mail.
    I've checked my mail settings and they are the same as before. Have OSX Yosemite 10.10.1 installed.

    ''SuperSluether [[#answer-671002|said]]''
    <blockquote>
    Is this problem in Firefox? It sounds as if you are referring to an email program such as Apple Mail or Mozilla Thunderbird. As far as I know, you can't open emails in Firefox with File > Open Message because there is no such option.
    </blockquote>
    Thank you for your response. I finally found out why this was happening. It had to do with the Trackpad settings for my Mac. I adjusted the track speed to a slower speed as it was set quite fast. This seems to have fixed the problem :)
    I’m not too computer savy so sometimes things can be a little confusing trying to figure out whats what and where to look for solutions.
    Thank you

  • Opening folders and files with enter/return instead of clicking

    in finder i've found that i can open any folder/file with command-o. however, not all apps support that and sometimes i really need the way to open the file/folder with return key or enter one. and it's impossible)) so i have to take my mouse and click. any possible solution to make this "windowsy" behaviour here, on the mac?

    In most all situations, when opening a file, you can use Command+Down Arrow to open it. Also, if you are in finder, you can use Command+Up Arrow to go up to the parent folder.

  • Make App in XCode that opens Applescript Files

    I feel this is a simple goal, but since I'm a total noob I have been having a hellish time getting this project off the ground, here's what I want to do:
    Make a program with buttons that I can click that will perform functions that I've already defined using applescript.
    In other words, in the window (of the app I want to make) there will be a button for each applescript, clicking on the button will perform a certain scripts function.
    Every guide I have found for using Xcode and Interface Builder has been for version 2.x and earlier. This is particularly frustrating for IB because many of the palettes/functions are totally gone or moved. I would love some advice that directly addresses the program I am trying to build, but a guide or how/to or SOMEthing would be useful too. Thanks in advance for even reading this.

    Hmmm, not sure where that other link came from, but referring to the AppleScriptObjC Release Notes, setting properties to missing value and creating handlers with a single trailing underscore in the name (and having only one parameter) will have them show up in *Interface Builder*. As an example, suppose you have the following in your AppDelegate.applescript file:
    property myButton -- this will be an instance of your button
    to doButtonStuff_(sender) -- this will do stuff when the button is pressed
    display dialog sender's |title|() as text -- just show the name of the button
    end doButtonStuff_
    From IB (open your project's MainMenu.xib), drag a button into the window, and select the *Connections Inspector* for the AppDelegate.applescript - you should see your property and handler listed under the Outlets and *Received Actions* sections. To link the button to items in your script, drag a connection from these items to your button - when connected, an outlet will be linked to your myButton property (so you can use it with various button methods), and an action will be linked to your doButtonStuff handler (which will call the handler when the button is pressed).
    From there, you can add and connect interface items as desired - your handlers can contain normal AppleScript statements to do whatever.

  • Files open empty/blank

    I am working with the most recient version of Dreamweaver CC(13.2 build 6466) on Mac os 10.9.2. Most of my files reside on servers in the building connected through eithernet. I have editied these file on the file servers for years and not had a problem. All of a sudden when I try to edit them, while they are on the server, Dreamweaver opens them to empty/blank files. I know they are not blank because I can open them in other text editors and the code is there. When I copy the files to my desktop the file opens with out a problem. I don't have my pages setup as sites because that dosn't work in my Magento work flow. As far as I know nothing about my network has changed.

    I Deleted the cache and then renamed the Configuration folder and neither had any effect. I have a virtual Windows 7 machine on this system. The Win 7 system is hosted with Parallels. I relized that the file(s) that I was trying to access was not on a server, those files seem to work, it was on this virtual win 7 system. I have recently upgraded the Mac OS to Marverics and in that proccess I updated Parallels. I am going to check with Parallels to see if the issue resides with them.

  • Applescript to open word doc directly in word

    I have hundreds of old word files that I would like to convert to pdf format.
    Im running OSX 10.6.8 and Word 2008 (12.3.3).
    When I go to open the files in the finder, I get an error from Word that says:
    "The file type is blocked from opening in this version. To help secure your computer, some file types are blocked from opening when you double-click the fire or drag the file to the Microsoft Word icon,  If you trust the file is secure, you can open the file by clicking Open on the File menu."
    From the official Microsoft support page it says the following:
    "Consider the following scenario. In Microsoft Word 2008 for Mac, you try to open a document that was created in an earlier version of Microsoft Word for Mac. To do this, you use one of the following methods:
    You double-click the document.
    You drag a document to the Word 2008 for Mac program icon.
    You drag a document to the Word 2008 for Mac program icon that is in the Dock.
    You run an AppleScript that uses the Finder to open a Microsoft Word document.
    In this scenario, the document does not open as expected in the Word for Mac program."
    When I open the file as suggested (open Word, choose File>Open, select file), it opens.
    I created the following applescript, which I though would be the same as using Word to open the file:
    set x to choose file
    tell application "Microsoft Word"
        activate
        open x
    end tell
    For some reason, running this script gives me the same error as trying to double click the file in the finder.  Is my syntax in the above script still somehow trying to use the finder to open the file?  Is there anyway to automate this?

    Maybe you would like to try the following script. The Word document must be on the desktop though.
    set x to choose file default location (path to desktop)
    tell application "Finder"
        -- Get the name of the file (without the name extension):
        set theName to name of x
        set P to offset of "." in theName
        set theName to text 1 through (P - 1) of theName
    end tell
    tell application "Microsoft Word" to activate
    tell application "System Events"
        tell process "Microsoft Word"
            keystroke "o" using {command down}
            delay 1
            keystroke "d" using {command down} -- desktop
            keystroke theName & return -- open the file
        end tell
    end tell
    Message was edited by: Pierre L.

Maybe you are looking for

  • How do you use #REGION_STATIC_ID#

    We are doing some calculations using javascript on a tabular form region and I believe I should be using the #REGION_STATIC_ID#. However, I don't understand how to use it. Currently, we are running the page and then viewing the source to determine th

  • XML element tag problem

    Hi guys, I am facing a problem in parseing a XML file when the element is in <element/> tag format. Iam using "javax.xml.parsers.SAXParser" to parse the XML. Basically XML contains many fields that are mandatary in my XSD. my requirement is that if t

  • CD Amount

    Hi, Wat is <b>CD Amount</b>?? In which table it has.... Plz Tell me soon... Thanks & Regards, <b>Anil Kumar</b>

  • Cyndyfromo

    My e-mail messages don't appear or pop up when I get an e-mail.  How do I correct this?

  • L have a replacement ipad and my icloud back is from an old os system. how can I access it?

    Please help