Two questions regarding shell scripts in automator

they are both concerning this script:
I pass it an .avi file (I believe it could also take more than one), and outputs a converted file (that is playable on appletv2) that is dumped in my "Converted" folder.  This all works fine and dandy.
However, I would like to have it prompt the user for a destination folder, and pass that in as well.  However, I do not know how I would refer to that variable separately.
Handbrake's CLI application also produces output that shows what percentage the conversion is at, and although the script passes this output as it's own output (to the next automator action - I actually discovered this only by accidentally leaving a "Speak Text" action in), I want to be able to see this output in real time.  Is there anyway to do this?  Thanks for the help!

To be clear, this is what you mean, correct?
for outpath; do :; done
for f in "$@"
do
    if [ "$f" != "$outpath" ];
          thenof="$outpath"/`basename "$if" .avi`.mp4
    /Applications/HandBrakeCLI -i "$if" -o "$outpath" --preset="AppleTV 2"
    fi
done
I assume that "Ask For Finder Items" also passes it's input along to the next action?  Would "Get Value of Variable" do the same thing?  (I also use the same workflow to convert .mkv files and copy .srt files to the same destination folder, so I need to access the source files multiple times to filter out different files each time).
I would just test it myself, but I am not at my computer right now.
And this is kind of off topic, but since automator actions can be written in shell script, could this be easily made into one? How much work would it involve? 

Similar Messages

  • 3 questions regarding duplicate script

    3 questions regarding duplicate script
    Here is my script for copying folders from one Mac to another Mac via Ethernet:
    (This is not meant as a backup, just to automatically distribute files to the other Mac.
    For backup I'm using Time Machine.)
    cop2drop("Macintosh HD:Users:home:Desktop", "zome's Public Folder:Drop Box:")
    cop2drop("Macintosh HD:Users:home:Documents", "zome's Public Folder:Drop Box:")
    cop2drop("Macintosh HD:Users:home:Pictures", "zome's Public Folder:Drop Box:")
    cop2drop("Macintosh HD:Users:home:Sites", "zome's Public Folder:Drop Box:")
    on cop2drop(sourceFolder, destFolder)
    tell application "Finder"
    duplicate every file of folder sourceFolder to folder destFolder
    duplicate every folder of folder sourceFolder to folder destFolder
    end tell
    end cop2drop
    1. One problem I haven't sorted out yet: How can I modify this script so that
    all source folders (incl. their files and sub-folders) get copied
    as correspondent destination folders (same names) under the Drop Box?
    (At the moment the files and sub-folder arrive directly in the Drop Box
    and mix with the other destination files and sub-folders.)
    2. Everytime before a duplicate starts, I have to confirm this message:
    "You can put items into "Drop Box", but you won't be able to see them. Do you want to continue?"
    How can I avoid or override this message? (This script shall run in the night,
    when no one is near the computer to press OK again and again.)
    3. A few minutes after the script starts running I get:
    "AppleScript Error - Finder got an error: AppleEvent timed out."
    How can I stop this?
    Thanks in advance for your help!

    Hello
    In addition to what red_menace has said...
    1) I think you may still use System Events 'duplicate' command if you wish.
    Something like SCRIPT1a below. (Handler is modified so that it requires only one parameter.)
    *Note that the 'duplicate' command of Finder and System Events duplicates the source into the destination. E.g. A statement 'duplicate folder "A:B:C:" to folder "D:E:F:"' will result in the duplicated folder "D:E:F:C:".
    --SCRIPT1a
    cop2drop("Macintosh HD:Users:home:Documents")
    on cop2drop(sourceFolder)
    set destFolder to "zome's Public Folder:Drop Box:"
    with timeout of 36000 seconds
    tell application "System Events"
    duplicate folder sourceFolder to folder destFolder
    end tell
    end timeout
    end cop2drop
    --END OF SCRIPT1a
    2) I don't know the said error -8068 thrown by Finder. It's likely a Finder's private error code which is not listed in any of public headers. And if it is Finder thing, you may or may not see different error, which would be more helpful, when using System Events to copy things into Public Folder. Also you may create a normal folder, e.g. named 'Duplicate' in Public Folder and use it as desination.
    3) If you use rsync(1) and want to preserve extended attributes, resource forks and ACLs, you need to use -E option. So at least 'rsync -aE' would be required. And I rememeber the looong thread failed to tame rsync for your backup project...
    4) As for how to get POSIX path of file/folder in AppleScript, there're different ways.
    Strictly speaking, POSIX path is a property of alias object. So the code to get POSIX path of a folder whose HFS path is 'Macintosh HD:Users:home:Documents:' would be :
    POSIX path of ("Macintosh HD:Users:home:Documents:" as alias)
    POSIX path of ("Macintosh HD:Users:home:Documents" as alias)
    --> /Users/home/Documents/
    The first one is the cleanest code because HFS path of directory is supposed to end with ":". The second one also works because 'as alias' coercion will detect whether the specified node is file or directory and return a proper alias object.
    And as for the code :
    set src to (sourceFolder as alias)'s POSIX Path's text 1 thru -2
    It is to strip the trailing '/' from POSIX path of directory and get '/Users/home/Documents', for example. I do this because in shell commands, trailing '/' of directory path is not required and indeed if it's present, it makes certain command behave differently.
    E.g.
    Provided /a/b/c and /d/e/f are both directory, cp /a/b/c /d/e/f will copy the source directory into the destination directory while cp /a/b/c/ /d/e/f will copy the contents of the source directory into the destination directory.
    The rsync(1) behaves in the same manner as cp(1) regarding the trailing '/' of source directory.
    The ditto(1) and cp(1) behave differently for the same arguments, i.e., ditto /a/b/c /d/e/f will copy the contents of the source directory into the destination directory.
    5) In case, here are revised versions of previous SCRIPT2 and SCRIPT3, which require only one parameter. It will also append any error output to file named 'crop2dropError.txt' on current user's desktop.
    *These commands with the current options will preserve extended attributes, resource forks and ACLs when run under 10.5 or later.
    --SCRIPT2a - using cp(1)
    cop2drop("Macintosh HD:Users:home:Documents")
    on cop2drop(sourceFolder)
    set destFolder to "zome's Public Folder:Drop Box:"
    set src to (sourceFolder as alias)'s POSIX Path's text 1 thru -2
    set dst to (destFolder as alias)'s POSIX Path's text 1 thru -2
    set sh to "cp -pR " & quoted form of src & " " & quoted form of dst
    do shell script (sh & " 2>>~/Desktop/cop2dropError.txt")
    end cop2drop
    --END OF SCRIPT2a
    --SCRIPT3a - using ditto(1)
    cop2drop("Macintosh HD:Users:home:Documents")
    on cop2drop(sourceFolder)
    set destFolder to "zome's Public Folder:Drop Box:"
    set src to (sourceFolder as alias)'s POSIX Path's text 1 thru -2
    set dst to (destFolder as alias)'s POSIX Path's text 1 thru -2
    set sh to "src=" & quoted form of src & ";dst=" & quoted form of dst & ¬
    ";ditto "${src}" "${dst}/${src##*/}""
    do shell script (sh & " 2>>~/Desktop/cop2dropError.txt")
    end cop2drop
    --END OF SCRIPT3a
    Good luck,
    H
    Message was edited by: Hiroto (fixed typo)

  • Can't enter shell scripts in Automator?

    When adding the "Run Shell Script" action to a workflow in Automator, I can't actually type anything in the text box -- when I try to type something, I just get a bunch of seemingly random characters. Does anyone else see the same behaviour or is there just something funky going on with my two Macs?
    I'm certain I'd be able to create a couple of services for encrypting/decrypting messages in Mail with GPG, if only I could actually type the shell script into Automator

    Redemption Code http://helpx.adobe.com/x-productkb/global/redemption-code-help.html

  • Duplicate Text From Shell Script in Automator

    I'm trying to run a automator script that allows me to select a couple of files, run a sha1 checksum, and output a text file. My current version works 100% within the automator app, however when I use it as a context menu service, it outputs duplicate text. Here's my current workflow and what it outputs.
    Get Selected Folder Items
    Run Shell Script
    Copy to Clipboard (I've tried "new text file", and "new textedit file" as well)
    Outputs:
    SHA1(~/Desktop/Actions/Test/TEST.atn)= 88902acfb51e0f9a0c6dbedce69ce9618e26bc00
    SHA1(~/Desktop/Actions/Test/TEST.atn)= 88902acfb51e0f9a0c6dbedce69ce9618e26bc00
    Any help would be appreciated.

    Snow Leopard's Services workflow is automatically passed the type of selected items (that is what the selections at the top of workflow window are for), so just remove the *Get Selected Finder Items* action, since that is having the result of doubling the input items.

  • Capturing output of shell script in Automator

    I have an Automator work flow that includes the execution of a shell script.  The script in turn executes a Perl script and captures its output on a file.  This may sound a bit convoluted, but the Automator part was intended to automate disparate scripts that were already made, so I just "glued" them together.
    The shell script is like this:
    cd "/Users/username/Documents/Development/"
    ./script.pl "$1" 2>&1 >out.log
    The problem is that, after execution, "out.log" contains the output from STDOUT, but not STDERR.  I know because if I run "script.pl" from the Terminal, I get not only the normal output, but a couple of errors or warnings spit out by the script.
    I was under the impression that "2>&1>out.log" would redirect STDERR to the filehandle used by STDOUT, and then redirect STDOUT to the file, with the ultimate result of redirecting both filehandles to the output file.
    Is there something I'm missing?  How can I capture the STDERR from the script as well?  Keep in mind that the shell script is executed from an Automator work flow.
         Thanks!
         -dZ.

    ./script.pl "$1" >out.log 2>&1
    It is important to redirect in the correct left-to-right order.
    First move STDOUT (file descriptor 1) to the file, THEN move STDERR (file descriptor 2) to where STDOUT is NOW pointing.
    You moved STDERR first, then moved STDOUT, leaving STDERR behind.

  • Problems using Shell scripts and Automator

    My problem is that when I use the "Run Shell Script" Automator action, it won't work if I type the script inside the action but it will work if I just type a path to the script file, which is less elegant as I then need to copy the Automator app made as well as the script file.
    Here is the script I am trying to use
    #!/bin/bash -f
    if test -f ~/Library/Preferences/SPACE.com/Pro/Registration\ File
    then
    open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
    else
    ditto /Library/Management/Preferences/StarryNight/SPACE.com ~/Library/Preferences/SPACE.com
    open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
    fi
    exit 0

    Well I found the problem. Or at least I got it to work. I tried typing simple commands and scripts into the Shell Script action and had no issues with it running. So I then slowly expanded and typed out my script:
    #!/bin/bash -f
    if test -f ~/Library/Preferences/SPACE.com/Pro/Registration\ File
    then
    open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
    else
    ditto /Library/Management/Preferences/StarryNight/SPACE.com ~/Library/Preferences/SPACE.com
    open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
    fi
    exit 0
    Having typed it out in the script it runs fine. It seems you can't paste text into the action. To test this hypothesis, I copied the working script out of automator into BBedit and then back into Automator, the script no longer worked. Not sure why that is happening, but it does work if I type the scripts out.

  • Can't add "Run Shell Script" in Automator

    When I drag "Run Shell Script" to the right pane in Automator nothing happens. All other applications I've tried can be dragged to the right pane. In the system.log I can find the following message:
    Feb  7 16:56:48 Bananaboat Automator[195]: Error : -[AMWorkflowView _addAction:Kör kommandotolksskript] : * -[NSTextView replaceCharactersInRange:withString:]: nil NSString given.
    "Kör kommandotolksskript" is "Run Shell Script" in Swedish.
    Any ideas how to fix this?

    You might have a corrupted file in the action, in which case you could reload it with something like Pacifist. You can't get the digest of a directory, so for comparison, compressing a copy of /System/Library/Automator/Run Shell Script.action on my desktop gives me the following:
    sha1 digest: c209b69777f6a3301d72ddf0eb0ad4e7d4230741
    md5 digest: 09e4ade9056ada3294ffb93bd16de1a7

  • Why has the sql statement been extucted two times in shell script?

    I tried to test rac load balance using the following shell script on suse 10 + oracle 10g rac.
    oracle@SZDB:~> more load_balance.sh
    #!/bin/bash
    for i in {1..20}
    do
    echo $i
    sqlplus -S system/oracle@ORA10G <<EOF
    select instance_name from v\$instance;
    EOF
    sleep 1
    done
    exit 0After execute shell script, I got the follow result.
    oracle@SZDB:~> ./load_balance.sh
    1
    INSTANCE_NAME
    ora10g2
    INSTANCE_NAME
    ora10g2
    2
    INSTANCE_NAME
    ora10g1
    INSTANCE_NAME
    ora10g1
    3
    INSTANCE_NAME
    ora10g1
    INSTANCE_NAME
    ora10g1Seem the sql statement has been executed two times in each loop. If you feel free please help to have a look. Thanks in advance.
    Robinson

    You can end a SQL command in one of three ways:
    * with a semicolon (;)
    * with a slash (/) on a line by itself
    * with a blank line
    A semicolon (;) tells SQL*Plus that you want to run the current command that was entered. SQL*Plus processes the command and also stores the command in the SQL buffer.
    A blank line in a SQL statement or script tells SQL*Plus that you have finished entering the command, but do not want to run it yet, but it's stored the command on SQL Buffer.
    A slash (/) on a line by itself tells SQL*Plus that you wish to run the command stored on SQL buffer.

  • Two questions regarding versions 1.5 and 2.0

    I am going back a few years I know, but can any subject matter expert coach me on two questions related to version 1.5 or 2.0?
    First, may I use these versions to place subtitles/captions into videos?
    Second, may I also either import prerecorded voiceovers (say as .wav files or other formats) and put them into my videos or record voiceovers natively within 1.5 or 2.0 into my videos?
    Many thanks.

    Premiere 1.5/2 does not do captions but yes you can use the Titler to add subtitles or even Encore.
    Yes you can import wave or record your own voice over.
    You probably need to read this first.
    Error: Activation Server Unavailable | CS2, Acrobat 7, Audition 3 

  • Two questions regarding Sun exams

    what is the differences between these two exams?
    *1 - Sun Certified Web Component Developer for the Java 2EE Platform*
    *2 - Sun Certified Web Component Developer for J2EE 1.4*
    as I see in my prometric history, I passed second exam but enrolled for first exam.
    second question is:
    in prometric website, it shows me that I enrolled for following:
    Sun Certified Business Component Developer for the Java 2 Platform 1.3, Enterprise Edition
    but not for :
    Sun Certified Business Component Developer for the Java Platform, Enterprise Edition 5
    why? do I have to pass the former in order to pass the SCBCD 5?
    thank you very much in advance

    1) see the website for descriptions
    2) you can sign up for either, you signed up for the one and not the other.

  • How to perform addition of two numbers in shell scripting in Solaris-10

    Hi,
    I have a sh script which contains the following line
    TOTAL=$((e4-s4)) -> Where e4 and s4 are input got from the user.
    At the time of execution of this line the following error occurs
    test.sh: syntax error at line 8: `TOTAL=$' unexpected
    How to solve this issue?. Can any one help me please?.........................
    Regards
    Revathi

    Again Same error persisted.
    Below is my script
    +#!/bin/bash+
    echo "Enter the start IP"
    IFS="."
    read s1 s2 s3 s4
    echo "Enter the End IP"
    IFS="."
    read e1 e2 e3 e4
    TOTAL=$(($e4 - $s4))
    echo "Total is $TOTAL"
    The output is
    *#!/bin/bash*
    echo "Enter the start IP"
    IFS="."
    read s1 s2 s3 s4
    echo "Enter the End IP"
    IFS="."
    read e1 e2 e3 e4
    TOTAL=$(($e4 - $s4))
    echo "Total is $TOTAL"
    Any idea

  • Question regarding PowerShell script to Uninstall security updates in Windows 7/8

    Hello Everyone,
    I came across a great link on the Scriptcenter  
    https://gallery.technet.microsoft.com/scriptcenter/Uninstall-security-update-76f2dcb7  which has a PowerShell download that enables you to remove Microsoft updates from computers.  When I download the zip files ->extract it,  I have a
    file called " UninstallHotFix.psm1 ".   So far so good.  But where I am totally lost is in the directions to use this file. 
    Specifically: 
    Method 1:
    Download the script and open the script file together with Notepad or any other script editor.
    Scroll down to the end of the script file, and then add the example command which you want to run.
    Save the file then run the script in PowerShell
    I assume (1) refers to right clicking on "UninstallHotFix.psm1" and opening it with notepad?
    If I want to run the following...    Uninstall-OSCHotfix -HotFixID KB2830290   do I just paste it at the end of notepad?
    Do I save the file and attempt to run in powershell as a .psm1 file - or as a .ps1  file?
    Lost in Space....
    Adrian

    Hi Adrian,
    If the above doesn't help, I recommend posting questions about this item on the QandA tab of the script module:
    https://gallery.technet.microsoft.com/scriptcenter/Uninstall-security-update-76f2dcb7/view/Discussions#content
    I'd recommend following the steps in Method 2 on the gallery item. As an overview:
    1. Save the zip file into C:\Temp
    2. Extract the zip to C:\Temp\UninstallHotFix(PowerShell)
    3. Open a PS console and type the following:
    Import-Module 'C:\Temp\UninstallHotFix(PowerShell)\UninstallHotFix(PowerShell)\UninstallHotFix.psm1'
    You can verify that the module has been loaded by running Get-Module:
    PS C:\> Get-Module
    ModuleType Version Name ExportedCommands
    Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint
    Script 0.0 UninstallHotFix {Uninstall-OSCHotfix, UninstallHotFix}
    Don't retire TechNet! -
    (Don't give up yet - 13,225+ strong and growing)

  • Two Questions regarding the P965 Platinum Board

    EDIT:  I've removed my second questions and reposted it in the overclocking forum since that's where it belongs. ( https://forum-en.msi.com/index.php?topic=106416.0 )
    I've recently built a system using the P965 board.  I've got a Watercooled E6300 Processor, eVGA 8800GTX Superclocked video card, 2GB of Corsair XM2 DDR2 800 Ram, 700w thermaltake PSU.
    Question:  Someone told me that this board doesn't like NVIDIA cards running in SLI.  I've got one 8800GTX but hope to add a second one down the road.  Is this actually an issue for this board?  Is there a workaround of any kind?

    Quote
    My homework consisted of 4 or 5 reviews of the motherboard and newegg.com specifications/user reviews.
    If they mentioned SLI they were not very good reviews.  And if they didn't, well, what does that tell you?
    Quote
    Is there a workaround of any kind?
    Anyway. As I said before.  SLI is not impossible.  I am sure that there are or will be modded drivers for the 8800-cards that should allow you to operate two cards in SLI-mode.  A friend of mine used modded drivers to run two 7800 cards in SLI-mode on the 975X Platinum PUE.
    Just note, that on the 975X the two PCIe-x16-Slots work as x8/x8 in Crossfire-mode.  Since the secondary PCIe-Slot on the 965 Platinum only supports x4 you would have considerably limited bandwith even with Crossfire. 

  • Two Questions regarding paypal balances.

    First question I'm fairly new to using paypal however sometimes when I attempt to withdraw from my account it gives me an internal error and won't allow me to do it for sometimes several hours, what causes this? Second Question - It shows my current withdrawals as complete however no money has shown up in my bank (it has only been 2 days) but how come it shows up as complete on paypal?

    Hi QuickQuestion24 1)Could be a glitch?2)https://www.paypal.com/selfhelp/article/FAQ1470/1

  • Question regarding "SaveDocsAsPDF" script adjustment

    Hello Scriptkiddies and Adobe guru's :-)
    Quite a while ago I obtained a script from this forum where someone adjusted some settings from the standard-included "SaveDocsAsPDF" script from Illustrator CS5, but I'm running into a few issues that I can't fix myself… I'm not a scripter unfortunately :-)
    The customized script currently converts a folder with AI files to PDF's with the "Smallest Filesize" setting. But there are 2 things I'm looking to include, and I'm hoping anyone here could help me out:
    - The produced PDF's are about 4 times as big as the PDF's that Acrobat Distiller produces with the same (standard) setting. I have no idea why this happens, but if someone has an enlightening idea or suggestion on how to make the script produce the smaller type of PDF's that Distiller manages to output, I would be forever grateful!
    - The second, and definitely the most important change I'm looking for, is that I would love to have an action included in the script where the script converts all text to outlines before creating the PDF… while not overwriting the current AI-file (which it already doesn't do). The issue is that a lot of our clients don't have the fonts that we at work use (some of which have PDF issues), so a PDF where the fonts have been outlined would solve that problem immediately.
    Is there anyone here who would be willing to help me out with this particular problem perhaps? I sometimes have 50+ PDF's to make, so this action is really a sanity-saver for me
    Sincerely,
    Joram

    One thing that stands out as being undesirable as far as best practices go is that you are placing code on objects (using the on() approach).  The proper approach is to assign instance names to your interactive objects and use them to place all of your code on the timeline where it is readily visible.  In doing so you may just find that alot of the code you show can be modularized into functions that can be shared by different objects rather than having each one carrying a full load on its back. You may find you can pass arguments to shared functions that make the same functions capable of supporting interactions with different objects
    Your on(press) call performs an unnecessary conditional test.  If you change the condition to be   if (project._currentframe != 25) you can avoid this.
    In your on(rollOver) call's set of conditionals, you have some lines that repeat in each condition, so they can be moved to the end outside the conditionals.
    Your on(release) call has the same issue as your on(press) call.  Also the overrun use of the _parent target is an indication that most of the code in this call would likely serve you better sitting in the _parent timeline, and your button could just call that function

Maybe you are looking for

  • How do i redeem itunes gift card online using linux

    I have bought my daughter a gift card but there appears to be no way to redeem this for her without installing itunes.  Next problem is that I would never install such software even if it worked in linux.  So where can I redeem it online for her usin

  • Com.sun.identity.authentication.spi.AuthLoginException:

    Hello - I'm currently trying to integrate IDM 7.1, Access Manager 7.1 and Directory Server 6.0... The problem that I am running into is trying to register Access Manager 7.1 as a resource in IDM: I am utilizing the Sun Java Access Manager Realm Resou

  • Solaris 8: Multiple primary interfaces connected to the same network

    I have a machine with Solaris 8, and it has multiple interfaces that are connected to the same network which means they all have metric 0 (1 hop) to the default gateway. assume: e1000g0: 192.168.30.70 e1000g2: 192.168.30.72 e1000g4: 192.168.30.74 e10

  • BCD to decimal and viceversa

    Hi, Am working on conversion of decimal to BCD (Binary coded decimal) and viceversa. I require BCD for calling Cobol from Java using JNI. Can anybody help me out in giving a pointer or an algorithm for doing the same. I Googled on the web for any inf

  • Parallel Execution Of Procedures

    Hi All, I have 4 procedures proc1,proc2,proc3 and proc4.I have to execute the procedures like below Proc1 will be executed first and after the execution of the proc1, it will trigger proc2 and proc3 to execute in parallel, if the execution of both th