Automator-Applescript Problem

I have got an Automator problem that is down mainly to Applescript (I believe) that is posted in the Automator category: http://discussions.apple.com/thread.jspa?threadID=1896508&tstart=0 . Please help, I really need an answer before midnight GMT.

Actions return their results in a list, so even though you are setting the input to "Stop", what the next action is getting is {"Stop"}. In your Run AppleScript action, you will need to look for your item in the input list - for example:
if the input contains "Stop" then
      -- or --
if the first item of the input is "Stop" then

Similar Messages

  • Help Needed: Automator Applescript for Folder Action - Encode Video

    Hi !
    I have created an Automator Applescript for a Folder Action to do the following:
    When a new video file is moved to the target folder (i.e. Download of Vuze is done), automatically launch the Applescript Action that does the followin g(Applescripted):
    1) Using "run shell script" and FFMPEG on a UNIX command line, determine Width/Height, Framerate, Bitrate
    2) Calculate encoding parameters (slightly reduced bitrate, reduced Aspect etc.)
    3) Using "run shell script" with ffmpeg on the command line and the calculated parameters to encode the video file
    At the same time, the action is written to a log file so I know if a file is recognized, when encoding started etc.
    It works fine if I save this Action as an .app, make an alias on the Desktop and drop video files on it.
    It also works fine if I attach the script to a folder as a folder action and drag a video file in there.
    However, when I attach the script as a folder action to the Vuze download folder, it encodes only some video files, i.e. if there was a download of 5 files, chances are good that it will not encode 1 or 2 files out of those 5.
    If for example a second download finishes while the encoding for the first download is still going on, sometimes the second file starts encoding after the first encode finishes, sometimes it does not, the file does not make the log file at all, i.e. the folder action missed it or the automator action dropped it because it was still encoding. Still, sometimes it happens, sometimes not.
    As I need a solution that is 100% accurate, I would like to ask if there are any ideas on how to do this better maybe? As I am not an Applescript Guru, I would need some help to know what works and what doesn't and what the syntax is.
    My main idea right now:
    Similar to how ffmpegX works with its "process" application, have a second script (as .app) that receives the files to be encoded from the automator action and puts them in a queue, then proceeds to encode this queue while the main automator action is free to receive the next file.
    Writing this second app is quite straightforward (a modified version of my current script) but I have some questions I need help with:
    1) How do I call another applescript from within an existing applescript that launches the new applescript in a new process?
    2) How do I pass parameters to this new applescript?
    3) In case of this "Queueing" Idea, once I called the external applescript the first time, how do I make sure when I call next time, that I don't open a second instance of this script but rather pass another queue item to the original instance to be processed?
    Or in general: Is there a better way to achieve this automatic encoding solution that I have not thought about?
    Alternatively:
    Does anyone know how to call the "process" application that comes with the ffmpegX package with the correct parameters to use as a queueing / processing tool?
    Thanks!
    Joe
    Message was edited by: Joe15000
    Message was edited by: Joe15000

    To do this, I created an Automator workflow with an Applescript snippet to change the 'media kind'.
    Here is the 'Run Applescript' workflow step code:
    on run {input, parameters}
              tell application "iTunes"
                        set video kind of (item 1 of input) to movie
              end tell
              return input
    end run
    Prior to this running, I have an 'Import Files into iTunes' workflow step.
    You can switch out 'movie' with: 'TV show', 'music video', or anything in ITLibMediaItemMediaKind.
    Good luck,
    Glenn

  • Execution of automator workflow problem

    I'm trying to execute an Automator workflow from an applescript, but the specific command won't work:
    <pre>
    set theScript to "path:to:the:script"
    tell application "Automator"
    activate
    execute theScript
    end tell
    </pre>
    For some reason, the command execute theScript just does nothing. I've verified that I've got the path right by substituting open theScript in its place successfully. It seems that the command execute is not working as described in the Automator 2.0 Applescript dictionary.
    Am I doing something wrong here? Or is this a bug in the Automator 2.0 Applescript dictionary?

    While I haven't answered my original question, I have found a workaround for calling an Automator 2.0 workflow from Applescript. Instead of saving the workflow as a workflow, you save it as an application and then open the application in finder. The code goes like this:
    <pre>
    set lf to path to library folder from user domain
    tell application "Finder" to open (alias (lf & "Scripts:foo.app:" as text))
    </pre>
    I found this at macosxhints.com; http://www.macosxhints.com/article.php?story=20071123181555282
    I still haven't found what was wrong with calling the workflow as a workflow using the commands in the Automator Applescript dictionary.

  • Automator, iMovie and Applescript problem

    Hi,
    I'm trying to convert a .mov file to .mp4 using Visualhub and automator, but a step in my automator file uses an applescript step that just causes the automator flow to stop and the end and not gon one with the rest of the actions.
    More specifically:-
    1. I use my HD camera to film something.
    2. Connect the camera to my mac.
    3. Import the video using iMovie.
    4. My Automator actions ask me to confirm that iMovie has finished the import
    5. Then Ask for finder items, which is get the newly imported .mov into VisualHub
    6. Run the problematic Applescript:-
    on run {input, parameters}
    --we need to unset the default timeout length of two minutes, we'll make it 45
    with timeout of (45 * 60) seconds
    tell application "VisualHub" to set VisualHub to load script (scripts path of main bundle & "/automation.scpt" as POSIX file)
    tell VisualHub
    LoadSettings("/Volumes/MyBook/hd.cam.settings.vhub")
    --SetSaveLocation("YOURHARDDRIVE:Users:YOURNAME:Desktop:iphonemovies:temp")
    AddFiles(input)
    StartConversion()
    QuitApp()
    end tell
    end timeout
    return input
    --delay 15
    end run
    Which I've used from this site (http://professafresh.wordpress.com/2007/10/18/fun-with-automator/) and just stopped the two lines with a comment marker.
    What is supposed to happen after that is that
    7. Automator asks to confirm that VisualHub has finished.
    8. VisualHub quits
    9. Finder finds the .mov that was created when the film was imported
    10. Finder then moves the item to the trash.
    So there is something going on with the applescript that causes the process to stop after the conversion.
    Some points:-
    1. I have used the VisualHub import and convert script step but the default settings are not what I'm after as I want the video resized to 960x540.
    2. iMovie recognizes and keeps all the head info as long as the file name is the same. So if you skip over the thumbnail in iMovie the timestamp changes to reflect the time that the video was taken. If you convert the .mov to .mp4 the info is retained but with a much smaller video size.
    I've tried to give as much info as possible, sorry if it's too much.
    Regards,

    iMoive and iPhoto are not free apps. If you purchased them on your iPhone they should available to download again on your new iPhone.
    -Doug

  • Automator/Applescript to Create New Pages Doc in Selected Folder

    When working in Finder I'd like to be able to create a folder, and then (still within Finder) create a number of Pages documents inside that folder. This would help in organizing complex projects, and would be preferable to creating the documents (from the bottom up) in Pages and then laboriously assigning each document to a different folder.
    I've tried various solutions in Automator and Applescript but nothing has worked.
    For example:
    try
    tell application "finder" to set myFolder to (folder of the front window)
    on error -- no open folder windows
    set myFolder to path to desktop folder
    end try
    tell application "Pages"
    activate
    set myDocument to make new document with properties {path:myFolder}
    end tell
    But this gets an error "Can't make [the selected folder] of application "Finder" into the expected type. (-1700).
    In automator, I've tried to do the following:
    1. Get Selected Finder Items (which will be the folder I want)
    2. (Create new variable "path" and drag onto 1., which creates "Get Value of variable)
    3. (ignoring input) Get Specified Finder Item (specifying a blank Pages document)
    4. (accepting input) Copy Finder Item to variable "path"
    The problem with this is that step 2 returns both the desired folder AND the desktop. The result of the entire process, moreover, is that the blank Pages file is created (or rather copied to) the desktop ONLY, and not to the desired folder.
    Anyway, I hope someone can help me with this. It would really speed up my organizing process.
    Wes

    Taking care of true window's properties is often useful
    on run
    try
    tell application "Finder" to set myFolder to (target of the front window) as alias
    on error -- no open folder windows
    set myFolder to path to desktop folder
    end try
    set myNewDoc to my makeNewIworkDoc("Pages", "myNewDocument" & my dateTimeStamp() & ".pages", myFolder as text)
    end run
    --=====
    Creates a new iWork document from Blank.template,
    saves it and returns its pathname.
    example:
    set myNewDoc to my makeNewIworkDoc(theApp, docName, folderPath)
    on makeNewIworkDoc(a, n, d)
    local t, c
    if a is "Pages" then
    set t to ((path to applications folder as text) & "iWork '09:Pages.app:Contents:Resources:Templates:Blank.template:") as alias
    else if a is "Numbers" then
    set t to ((path to applications folder as text) & "iWork '09:Numbers.app:Contents:Resources:Templates:Blank.nmbtemplate:") as alias
    else
    if my parleAnglais(theApp) then
    error "The application “" & a & "“ is not accepted !"
    else
    error "l’application « " & a & " » n’est pas gérée !"
    end if
    end if
    set f to d & n
    tell application a
    set c to count of documents
    open t
    repeat
    if (count of documents) > c then
    exit repeat
    else
    delay 0.1
    end if
    end repeat
    save document 1 in file f
    end tell -- theApp
    return f as alias
    end makeNewIworkDoc
    --=====
    on parleAnglais()
    local z
    try
    tell application "Numbers" to set z to localized string "Cancel"
    on error
    set z to "Cancel"
    end try
    return (z is not "Annuler")
    end parleAnglais
    --=====
    on dateTimeStamp()
    return (do shell script "date +P%Y%m%d-%H%M%S")
    end dateTimeStamp
    --=====
    Yvan KOENIG (VALLAURIS, France) vendredi 4 septembre 2009 20:51:02

  • Automator - applescript

    Step1: I wrote an applescript to process an excel file (deleting a few columns and rows).. When I compiled it in Applescript editor, it worked fine.. Gave no errors or warnings..
    Step2: I launched Automator. Selected 'Application'. And then selected 'Run Applescript' action. I pasted the same script in the 'Run Applescript' action of automator and when I compiled it, it is giving an error "The result of the numeric operation was too large". I don't know why this happens.. It was working fine before I upgraded to 10.6.2..
    Here's the script:
    on run {input, parameters}
    repeat with eachfile in input
    set theWorkbookFile to eachfile
    tell application "Microsoft Excel"
    open theWorkbookFile
    set theWorkbook to active workbook
    tell worksheet "Sheet1" of active workbook
    delete row 1
    delete column 1
    repeat with x from 39 to 10 by -1
    delete column x
    end repeat
    end tell
    save active workbook
    close active workbook saving yes
    end tell
    end repeat
    return input
    end run
    Since this works fine in applescript, i dont think this would be a problem.. Any help would be highly appreciated..

    yes but that's what I'm saying. just do it from applescript.
    on open these_items
    repeat with eachfile in these_items
    set theWorkbookFile to eachfile
    tell application "Microsoft Excel"
    open theWorkbookFile
    set theWorkbook to active workbook
    tell worksheet "Sheet1" of active workbook
    delete row 1
    delete column 1
    repeat with x from 39 to 10 by -1
    delete column x
    end repeat
    end tell
    save active workbook
    close active workbook saving yes
    end tell
    end repeat
    end open
    save it as an application from applescript editor and drop as many items as you want at once onto it. it will process them all.

  • Automator / Applescript Batch export

    Is it possible to create automator actions or applescript that will batch export a folder of keynote documents to .mov files?

    No you can't batch them all at once because Quicktime is used for rendering the slideshow and it's a one at a time operation. It might be done with Applescript but you'd have to ask over in the Applescript forum for help with that.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto (iPhoto.Library for iPhoto 5 and earlier) database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger or later), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 6 and 7 libraries and Tiger and Leopard. Just put the application in the Dock and click on it whenever you want to backup the dB file. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.
    Note: There's now an Automator backup application for iPhoto 5 that will work with Tiger or Leopard.

  • Need Help with scripting for Automator/AppleScript.

    Hi everybody,
    I am building a small app for my mac, What I need is a script that can rename a file that I drop on it.
    and example being:
    example.jpg
    (when I drop it on the app, I want the app to change the filename of the document to "Image.jpg"
    I have tried this with Automator, but it requires that I specify the file to be changed, what I need is something that will change the name of any file I drag onto it.
    I am using it for application specific files.
    Kind regards,
    Pete.
    iBook G4; 60GB Hard Drive, 512MB RAM, Airport Extreme    

    Open the Script Editor in the
    /Applications/AppleScript/ folder and enter the
    following:
    on open(the_file)
    tell application "Finder"
    set name of the_file to "Image"
    end tell
    end open
    Save this script as an application.
    (11347)
    this script compiled correctly; however when run it returned the following error "Can't set name of (the_file) to "Image.jpg"
    I am also given the option of editing the script or just quitting.
    thanks for your help

  • "batch" exporting to aiff using automator / applescript?

    I often find myself prepping a lot of audio for DV editing in Final Cut Pro....exporting audio out of QT to 48khz, 16bit, aiff.
    I'm looking for a way to do this to many files in 1 step....ie: drag and drop a folder/files onto an icon. Automator doesn't seem to have an export action under quicktime. And all i can do in applescript is tinker, at best.
    I downloaded the QT script package from the apple site.. http://www.apple.com/applescript/quicktime/ these seem like a good start, but im havin trouble tweakin them for .aiff audio
    any suggestions for doing this?

    can do this now with automator

  • Still no Automator / Applescript Support in iWorks 09

    Hi everybody,
    i find it extremly annoying that there are still no iWork Actions in Automator nor is there any native Applescript Support ! Come on Apple, even the bad guys at Microsoft do have Automator actions in their Office 2008 product. I bought iWork 08 i will not buy iWork 09. Am i the only person who would like to have support for automator and applescript build into the products ?
    cheers
    Ronny

    No, M$ feels they have to lead you by the hand. Apple knows there users are brighter and can do many things themselves.
    What are they going to make? How do they know what automator actions will be needed by the community until the scripting is out and available, And they see how we end up using the technology.
    Perfect example, they didn't introduce all 350+ functions available in XL in the numbers 1.0 version. They released about 150, then listened to the community to see what we wanted most. THEN they let their engineers go on those points, not WASTING their time and money creating stuff that nobody needs, or only 5% need. Now we have ~100 more functions, and even a new data type, duration, that XL doesn't have. why? because many people were trying to use Numbers to keep track of things like blood pressure logs, jogging logs, etc...
    Another real world example, college campus', Believe it or not the best designers of campuses do not put sidewalks in except for around the buildings themselves, not between them. Because they cannot predict what class patterns the students will end up having, or what habits they, as a group, will develop. They wait till about a year later, see where the grass has been worn down to paths and make sidewalks over those paths.
    This is classic design paradigms when you have a random, unpredictable user base that could require almost anything from you. Let them start by designing to fit their needs, then make official releases that take those concepts one step further and completely debugged and up to your standards.
    Just my second set of two cents,
    Jason

  • Automator Service problem

    Hello all.
    I'm trying to set up a Service in Automator, so that I can convert multiple image files into a single .pdf. It's all working fine, but I have one problem. I'd like the .pdf to automatically be saved in the folder in which the original image files came from.
    At the moment, my workflow allows the .pdf to be created and deletes the original files (if I say yes when I'm asked for confirmation) but I can't figure out how to change the destination for the new .pdf to be the folder in which the original image files came from.
    My workflow is currently as follows:
    Set Value of Variable (1)
    New PDF from Images
    Name Single Item
    Move Finder Items
    Ask for Confirmation (Ignore Input)
    Get Value of Variable (1)
    Move Finder Items to Trash
    Any help greatly appreciated!

    See http://discussions.apple.com/thread.jspa?threadID=2241804 for a four-parter by Sal Saghoian on *Automation in Snow Leopard* and then, this, which describes old and new automator—services stuff:
    http://www.reynoldsftw.com/2009/08/automator-and-finder-interactions-in-os-x-10- 6/

  • Automated Webservice problem

    hi all
    I am new to BPM.I was trying a example with two human activities and a automated activity.
    I am using webservice as my automated activity. I am passing some parameters to web service through a human activity and capturing webservice output in another human activity . The problem is my web service is not getting executed .The default  trace shows "There is no hashtable registered for java.lang.String class. Maybe there is a class loader problem."
    Please help in resolving this.
    Thanks
    Monika

    Hi Monika,
    Did you have a look at "Manage Processes" in NWA to verify that your process started correctly - well in case you were able to access the first human activity then this should be the case. Nevertheless this perspective should list your process. Once selected you can find a tab called "History" at the bottom of the page. Switch the view to "advanced" and see the result of the service call. If it was successful the history will log it. If there was some error either the history will log it or the problem will be part of the default trace.
    I think the "hashtable + String" message you mentioned is not directly related to this problem.
    Cheers,
    Martin

  • Non .Mac publish with Automator / AppleScript?

    Hi folks!
    Currently I am using the following procedure to publish my iWeb site to my ISP:
    - "publish to folder..." option in iWeb
    - copy saved content from an extra folder over the new one (slideshow, PHP tweaks, small images)
    - sychronize local and remote folder with Captain FTP (only updated files)
    Is there any way to script these steps using the Automator (or even apple script)? Unfortunately it seems neither iWeb nor Captain FTP is "Automator-enabled" as I couldn't find any actions of them...
    Bye, Matthias
    iBook G4, Mac mini   Mac OS X (10.4.4)  

    So how does Captain Ftp check which file has been changed?
    By size or date?
    I have been thinking about doing something similar with Transmit.
    The problem is that you can't check the date since you have to export all the pages when you do an export. It's all or nothing with iWeb.
    That means that ALL the files gets updated.
    I created a simple worklow in Automator that uses ftp to transfer the specific blog-directories.
    So that I don't have to ftp my whole site everytime I update my blog.
    Unfortunately, I have to upload my whole blog every time since the file naming convention is a bit strange.
    Would have been better with a numbering system, or something else.

  • Automator/AppleScript for adding code to an html file

    Hi all,
    I have a bunch of files (60+) that have been converted from xml to html so that they can be read by the calibre eBook software. Because they were originally .xml files, they do not have opening or closing htiml or body tags. They won't open in Word, only textedit. I am looking for a way to insert the <html> <body> and </body> </html> codes into each file as quickly/painlessly as possible, ideally as a workflow, or series of workflows, that I could use later with other files of this type.
    Can anyone advise me on how to do this? I'm new at coding/applescript/automator, but I'm generally a quick study.

    This is an applescript version which should be a little more comprehensible.
    -- select files - might be easier ways to do this depending on your setup
    set fileList to choose file with prompt "Choose files to wrap in HTML tags" with multiple selections allowed
    -- loop through files
    repeat with thisFile in fileList
      -- open the file for writing
              set fp to open for access thisFile with write permission
      -- grab contents of file and wrap it in tags
              set unmodifiedText to read fp
              set modifiedText to "<html>" & return & "<body>" & return & unmodifiedText & return & "</body>" & return & "</html>"
      -- write the new text out to the file and close it.
              set eof of fp to 0
              write modifiedText to fp
              close access fp
    end repeat

  • COM Automation: getProperty problems

    Hi,
    I know that the topic of this post don't belongs to this subcategory, but really I cannot find where to put it.
    I'm implementing a solucion using Oracle COM Automation to use a DLL through its COM interface from PL/SQL. The connection is done ok, and I can instantiate the object, get properties, set properties, invoke methods, etc.
    The problem is that when I use getProperty to get a Property that's empty (null), it returns the last value for which getProperty obtained a valid value:
    COM Object
    - Property A. Value: 'dog'
    - Property B. Value: 'cat'
    - Property C. Value: '' (empty)
    Pseudocode:
    1- CreateObject using COM interface --> OK
    2- getProperty('A') --> dog
    3- getProperty('B') --> cat
    4- getProperty('C') --> cat
    So, as you can see, getProperty('C') returns the last value obtained in a getProperty that returned a value (getProperty('B)). Any of you has any clue on what could be wrong with the Oracle COM Automation method to access a COM interface?
    Thanks a lot in advance,
    Luis Miguel

    Sorry, I meant to say 12g is where it wont be included.
    The migration path is .NET stored procedures. You should also be able to call a COM object via via COM Interop, but you'd be breaking new ground there in a sense as I'm not sure that that is something Oracle has tested, and I haven't heard from other customers that are doing that, so if there are issues there you maybe the one to uncover them.
    Greg

Maybe you are looking for