Can I automate a Script with a dialog?

Hello everyone. I have an Applescript that I'd like to make completely automatic. The Applescript is a droplet app that converts audio files into AAC, AIFF, Loseless, WAV or MP3 by using iTunes. After choosing your desired format from a menu, it asks where you'd like to save it, desktop or otherwise. Then it finally goes to work. Basically, the dialogs are slowing me down. I'd like the script below to automatically convert to MP3 and place the resulting MP3 onto the desktop.
If anyone could help me out, I'd be very grateful. Thanks.
"Drop A Few My Way" for iTunes
written by Doug Adams
[email protected]
Drag and drop files to this droplet
to convert each file with an iTunes encoder
selected on the fly, restoring your
Preferences-set encoder afterwards
Each converted file is saved to the Desktop,
or other user-selected folder.
Tracks added to iTunes are deleted. Track properties
are not transferred between original and converted track.
It will be as though iTunes "never saw them".
Uses some UNIX shell scripting; OS X only.
v1.0 mar 9 04
initial release
Get more free AppleScripts and info on writing your own
at Doug's AppleScripts for iTunes
http://www.malcolmadams.com/itunes/
property enc_list : {"AAC", "AIFF", "MP3", "WAV"}
property encoder_possibilities : {".m4a", ".aif", ".mp3", ".wav"}
property errTxt : ("(One or more files may not have been converted correctly.)" & return & return)
global filebefore_added_toiTunes -- place where file is dropped from
global fileafter_added_toiTunes -- reference to original dropped fileglobal
global orig_Track -- reference to original dropped track
global new_Track -- reference to converted track
global newFile -- reference to converted file
global backup_encoder -- stash encoder from Preferences
global uD -- path to folder where converted files will be saved
global newfilename_andextension -- name created from type of
global encoder_options -- list of encoders
global new_extension -- extension of new file, based on encoder selection
global encoder_type -- parse first item of selected encoder to get string to use in dialogs
global err_mess -- mention an error
on run
display dialog ("This is a droplet. Drop audio files on this script's icon to convert them.") buttons {"OK"} default button 1
error number -128
--set fs to (choose file) as list -- debugging
--carry_on(fs)
end run
on open fs
set err_mess to ""
carry_on(fs)
end open
-- ============================
-- main handler
on carry_on(fs)
-- plural for dialogs
set s to "s"
if (count of items in fs) is 1 then set s to ""
-- choose encoder
tell application "iTunes"
launch
set encoder_options to (get name of every encoder)
set backup_encoder to name of current encoder
end tell
--set m1 to "Convert the file" & s & " using..."
set selected_encoder to (choose from list encoder_options with prompt ("Convert the file" & s & " using...") default items (backup_encoder as list) without multiple selections allowed and empty selection allowed) as string
if selected_encoder is "false" then error number -128 -- exit if cancel
-- determine the file extension and the display text from selected encoder
repeat with i from 1 to count items of enc_list
if selected_encoder starts with (item i of enc_list) then
set new_extension to item i of encoder_possibilities
set encoder_type to first item of textto_list(selectedencoder, " ")
end if
end repeat
-- path to desktop as default, or whatever
set uD to (path to desktop from user domain) as text
if button returned of (display dialog "Save converted " & encoder_type & " file" & s & " to Desktop?" buttons {"Cancel", "Elsewhere", "Yes"} default button 3) is not "Yes" then
-- set m2 to ("Choose folder to save " & encoder_type & s & "...")
set uD to (choose folder with prompt ("Choose folder to save " & encoder_type & s & " to...")) as text
end if
-- ok, committed --
-- NOW load encoder
tell application "iTunes"
set current encoder to encoder selected_encoder
end tell
-- ok, do the dropped files
repeat with f in fs
copy f to filebefore_added_toiTunes
try -- skip bad files
with timeout of 30000 seconds -- plenty of time
fixfilename(file_before_added_toiTunes)
addto_iTunes(file_before_added_toiTunes)
-- get properties?
-- copy properties before moving and deleting?
convert_track()
end timeout
on error m number n
-- log (m & return & n)
-- restore_encoder()
end try
end repeat
-- restore encoder
tell application "iTunes" to set current encoder to encoder backup_encoder
-- comment the next 2 lines to keep from being notified
tell me to activate
display dialog (err_mess & "Done converting audio file" & s & " to " & encoder_type & ".") buttons {"Thanks"} default button 1 giving up after 3
end carry_on
--==============================================================
-- add file to iTunes given alias
-- sets 'fileafter_added_toiTunes' to location of file added (it may be different
-- from original if iTunes is managing files) to delete later
-- sets 'orig_Track' to reference to new track to delete later
to addtoiTunes(f)
tell application "iTunes"
try
set orig_Track to (add f)
set fileafter_added_toiTunes to (location of orig_Track)
on error m number n
--log (m & n) -- debugging
set err_mess to errTxt
end try
end tell
end addtoiTunes
to convert_track()
tell application "iTunes"
try
-- convert the original file
set new_Track to item 1 of (convert fileafter_added_toiTunes)
-- get path to new file
set fileafterconverted to location of new_Track
-- delete original track from iTunes
delete orig_Track
-- delete the new converted track from iTunes
delete new_Track
-- move new file to uD (Desktop or user selected location)
do shell script "mv " & (quoted form of POSIX path of fileafterconverted) & " " & (quoted form of POSIX path of (uD & newfilename_andextension))
-- the original file that was dropped
-- may have been copied to the iTunes
-- Music folder. Delete that copy.
-- Otherwise, if the two filepaths are the same
-- then don't delete.
-- Never delete the original dropped file
if (filebefore_added_toiTunes as text) is not (fileafter_added_toiTunes as text) then
-- delete fileafter_added_toiTunes
do shell script "rm " & (quoted form of POSIX path of fileafter_added_toiTunes)
end if
on error m number n
-- log (m & return & n) -- debugging
set err_mess to errTxt
end try
end tell
end convert_track
to fixfilename(file_before_added_toiTunes)
set finfo to get info for filebefore_added_toiTunes
set newfilename_andextension to ((text 1 thru -((length of name extension of finfo) + 2) of (name of finfo)) & new_extension)
end fix_filename
on texttolist(txt, delim)
set saveD to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to {delim}
set theList to every text item of txt
on error errStr number errNum
set AppleScript's text item delimiters to saveD
error errStr number errNum
end try
set AppleScript's text item delimiters to saveD
return (theList)
end texttolist

Try making the following modifications:
Replace…
--set m1 to "Convert the file" & s & " using..."
set selected_encoder to (choose from list encoder_options with prompt ("Convert the file" & s & " using...") default items (backup_encoder as list) without multiple selections allowed and empty selection allowed) as string
if selected_encoder is "false" then error number -128 -- exit if cancel
…with…set selected_encoder to "MP3 Encoder"
Then replace…-- path to desktop as default, or whatever
set uD to (path to desktop from user domain) as text
if button returned of (display dialog "Save converted " & encoder_type & " file" & s & " to Desktop?" buttons {"Cancel", "Elsewhere", "Yes"} default button 3) is not "Yes" then
-- set m2 to ("Choose folder to save " & encoder_type & s & "...")
set uD to (choose folder with prompt ("Choose folder to save " & encoder_type & s & " to...")) as text
end if
…with…set uD to (path to desktop from user domain) as text
Then optionally also remove…-- comment the next 2 lines to keep from being notified
tell me to activate
display dialog (err_mess & "Done converting audio file" & s & " to " & encoder_type & ".") buttons {"Thanks"} default button 1 giving up after 3

Similar Messages

  • When using Mavericks, how can I automatically replace 'i' with 'I' when typing?

    When using Mavericks, how can I automatically replace 'i' with 'I' when typing?
    It was easy to do prior to mavericks using system preferences (language and text), but now I can only submit a 2 letter word to replace, not a 1 letter word. I have tried using a space but it doesn't allow that. I would assume that most people would love to be able to type quickly without having to make uppercase I all the time (first world problem i know), so I can't understand why apple have removed this feature.

    There is the shift key, or text replacement approach, providing you have enabled two things:
    Edit > Substitution > √ Text Replacement
    System Preferences > Keyboard > TextClick + to add a replacement
    Replaceii[spacebar]
    With
    I[spacebar]
    Press return
    Quit System Preferences
    Now, when you type ii, you will see a pop-up offering I.
    In the OS X App Store, search for WordService. This free collection of Services will enable you to just type your content, select it, and then choose the Service item, “Initial Caps of Sentences.” It does what it says.

  • Can you run Action Scripts with Adobe Photoshop Elements 8?

    I have Photoshop Elements 5 and i cant find the 'Action' tab. Im considering buying Elements 8 but ONLY if i know for sure if i can use action scripts with it.
    Message was edited by: Jochem van Dieten

    Elements does not include Photoshop's Actions Palette function.  You can get an add on for elements that will is able to Play some Photoshop Actions in Elements. Not all Photoshop Actions actions can be played for some action use Photoshop features that are not in Elements like Photoshop Scripting. http://help.adobe.com/en_US/PhotoshopElements/8.0/Win/Using/WS961FF412-5006-4364-B315-1576 62B1F7E9.html
    http://hiddenelements.com/
    http://www.photokaboom.com/photography/learn/Photoshop_Elements/actions/1_actions.htm

  • Can I use java script with iWeb?

    I am quite pleased with iWeb for my web requirements, commercial and private, but I need to insert java script and don't know how or if iWeb accepts it.

    All custom code, including JavaScript, is pasted in the HTML Snippet.
    Read this : Using the HTML Snippet
    Everything you paste there, is your responsibility.
    iWeb happily publishes your code, whether it works or not. If not, mend it.
    See examples here :
         http://www.wyodor.net/_Demo/Fancy/Dynamic_Text.html
         http://www.wyodor.net/_Demo/html5/BlowUp.html
         http://www.wyodor.net/mfi/Maaskant/How_To.html
         http://www.wyodor.net/mfi/cultureclub/Movies.html
         http://www.wyodor.net/mfi/roodhout/How_To_Do.html
    You may have to learn HTML, CSS, JavaScript, AJAX, DOM and how iWeb creates its pages. Especially that.

  • Can iMovie automatically refresh itself with re-edited original photos?

    Using iMovie 10.0.7, I created a 14:58 slide show using 173 photos from Photos Library. When I played it from iMovie Theater on my Apple TV, the thousands of white specks I had spent Retouching in iPhoto had all re-appeared.  I am unable to reload the re-re-edited originals individually without starting from scratch and losing all the timing, titles and transitions that have already been finished.  I only want to replace a couple of dozen photos that are badly speckled, but that means importing to iMovie (creating duplicate images), finding the flawed image in the timeline, deleting it (i.e., putting it back into the iMovie library), then inserting the newer image.  Will iMovie not automatically refresh its copies from the original images?

    It is possible to edit 'in place' original media in an iMovie 10 library and the changes will appear in events and projects when iMovie is relaunched.  (I've tested this but it is an unsupported hack).  However, I assume that your original media is from your iPhoto library and I believe that this will not have been copied into the iMovie library but iMovie will have linked to the items in the iPhoto library.   It would seem that iMovie used the original rather than the edited iPhoto files.  I don't use iPhoto at all and don't know how it handles edited files.
    Geoff.

  • How to make system update with "use automatic configuration script" and an URL

    Hello,
    all our laptop using "use automatic configuration script" with an "accelerated_pac_base.pac" prxy setting.
    How can we make system update work with that ?
    And no way for us to by pass this proxy settings with
    Thanks

    I mean there is no general method which is capable of correcting all possible errors found by schema validation.
    For example if the validation says it expected to find an <organization> element or a <company> element but it found a <banana> element, there is no way to determine what repair is necessary.
    Anyway the requirement is fighting against the way things work in the real world. The purpose of validation is just to find out whether a document matches a schema. If it doesn't, then too bad. Send it back to be fixed or replaced. If you are having a problem because you repeatedly get documents which don't quite match your schema, then you need to train the users to produce valid documents or to give them tools which help them do that.

  • Data exchange Mainscript (SCRIPT) with script block (DAC)

    Is there any way to exchange data beetwen a Mainscript (SCRIPT) with
    user-dialoges and script block (DAC) in this way that the script in
    scriptblock can access to this data?
    Background: I write a DAC-Application with some script-blocks for
    reading and writing data to/from real devices. During the development
    I'd like to simulate all device accesses because I don'd have the
    devices in my office. I write all scripts with a branch for simulation
    an real measurement on startup.
    How can I execute a swich (simulation / mesurement) without changing
    all my scripts all times? Can a script read a variable anyway (Variable
    from Mainscript, Diadem-Uservariable or "Hilfsvariable" like L1)? 
    Can I fill "DeviceParam1V" with content of a variable?
    I could use a input channel connected with a formula-block for it. (The
    formula-block can read a variable.) But this way is uncomfortable an
    don't work for input blocks.
    Martin Bohm
    [email protected]

    Because the DAC Script is executed in its own runtime environment you cannot use the DIAdem variables as in a normal VBS or a SUD.
    Still, there are ways to exchange information.
    First of all by an extra channel as Input (you named it)
    Secondly, there are several variables you can use. Have a look at the Script DAC block. There are two fields called Parameter1 and Parameter2. And each signal you configure has a parameter of its own.
    Prior to starting the scheme, you can use a script to change the value of those parameters:
    Call DACObjOpen("Script-in1")
      VBSSignalParam(1) = "abc"
    Call DACObjClose("Script-in1")
    Is changing the parameter of the first signal that is configured.
    Call DACObjOpen("Script-in1")
      VBSParameter1 = "1st device parameter"
      VBSParameter2 = "2nd device parameter"
    Call DACObjClose("Script-in1")
    is changing the global device parameters.
    On the side of the Script DAC driver VBS you cann use the paramP funtion to access the signal parameter that corresponds to the actual channel (as referenced by ChannelnumberP)
    ' SFD_ReadChannel
    ' Zweck               : Lesen eines Wertes für den Kanal "ChannelNumberP"
    ' ChannelNumberP      | Kanalnummer aus dem Block-Dialog
    ' ParamP              | Vom Anwender definierte Variable aus dem Block-Dialog
    ' DataP               | Variable zur Rückgabe des neuen Kanalwertes. Diese
    '                     | Variable sollte zumindest auf einen gültigen Wert
    '                     | initialisiert werden.
    ' ErrorP              | Variable zur Rückgabe einer Fehlermeldung. Wird diese
    '                     | Variable gesetzt, stoppt DIAdem die Messung
    Sub SFD_ReadChannel( ChannelNumberP, ParamP, DataP, ErrorP )
    End Sub
    To acces the device Parameters, use the init function:
    ' SFD_Init
    ' Zweck               : Diese Prozedur wird während des Messungsstarts aufgerufen
    ' DeviceParam1V       | Erster Parameter, der vom Anwender im DAC-Block
    '                     | eingegeben werden kann
    ' DeviceParam2V       | Zweiter Parameter, der vom Anwender im DAC-Block
    '                     | eingegeben werden kann
    ' ErrorP              | Variable zur Rückgabe einer Fehlermeldung. Wird diese
    '                     | Variable gesetzt, stoppt DIAdem die Messung
    Sub SFD_Init( DeviceParam1V, DeviceParam2V, ErrorP )
    End Sub
    Ingo Schumacher
    Systems Engineer Sound&VibrationNational Instruments Germany

  • Use System Proxy Settings - when this is selected in FF v3.6.6, does it adhere to the same local IE proxy setting? We use a pac file configured in "Use automatic configuration script."

    Does anyone know what Firefox looks at locally on the PC when the "Use System Proxy Settings" setting is selected? It appears to be the default setting, recently changed from "No Proxy" of versions past...
    Our company uses a pac file specified in IE under "Use automatic configuration script" - with this new default, does it adhere to the same setting in:
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]

    I may be wrong but I think that the "Use System Proxy Settings" makes sense only on Linux and generally speaking "other OSes". As far as I know there is no generic proxy settings in Windows operating system.
    The one I know is in the registry part of Internet Explorer.
    So in my understanding in Windows, Use System Proxy Settings = No Proxy

  • How can I automatically close a dialog box using Javascript after I click the OK button to submit it?

    How can I automatically close a dialog box using Javascript after I click the OK button to submit it? I don't want to have to X out of the dialog box after I am done.
    Thanks
    Linda

    JS can not interact with open dialogs in any way, unless it's a dialog
    created in JS using the Dialog object.
    On Thu, Jul 24, 2014 at 11:13 PM, lindaeliseruble <[email protected]>

  • Photoshop CC 32Bit Script with Dialogs.

    http://forums.adobe.com/thread/1336205 I'm Having a problem with Photoshop CC trial 32bit version with scripts that have dialogs not work with my install also posted in general forum. Is it my install I can not believe a bug that bad would ever be released.  How do you shoot an error 22 message?

    Turned out to be a Preference file MachinePrefs.psp which worked in Photoshop CC 64bit cause CC32bit scripts dialogs not to work go figure. It may have to do with OpenCL support. In CC64bit I used Advance GPU setting and checked it. 32Bit  CC I can not check it with mt setup nvidia quadro 4000.

  • On my windows 8.1 pc (i5 processor with 8GB ram) I can't get the automatic update voor CS4 master collection. I removed my panda antivirus and still can't automatically update. somebody any suggestion?

    on my windows 8.1 pc (i5 processor with 8GB ram) I can't get the automatic update voor CS4 master collection. I removed my panda antivirus and still can't automatically update. somebody any suggestion?

    thanks for your reply.
    in Dutch it says that there are no updates available. I know that after
    installing cs4 there are updates but i can't load them automatically. I did
    a delete and reinstall, but still get the message.
    kind regards,
    2014-09-23 16:28 GMT+02:00 Atul_saini123 <[email protected]>:
        on my windows 8.1 pc (i5 processor with 8GB ram) I can't get the
    automatic update voor CS4 master collection. I removed my panda antivirus
    and still can't automatically update. somebody any suggestion?  created
    by Atul_saini123 <https://forums.adobe.com/people/Atul_saini123> in *Downloading,
    Installing, Setting Up* - View the full discussion
    <https://forums.adobe.com/message/6755843#6755843>

  • HT2534 how can my daughter and i have our own itunes accounts on one computer because it automatically logs on with mine?

    how can my daughter and i have our own itunes accounts on one computer because it automatically logs in with mine?

    Hi theirmimi,
    Go to Manage your Apple ID (on a computer) and sign in with your Apple ID. Then you can edit the email information on your account:
    https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/
    Cheers,
    GB

  • First Script: Need some basic skill help? Can you add an image with a click?

    Hello, Im working on a project were you can replace people heads in a photo. Its for a project so its not supposed to be perfect. So far heres what i think the best steps to take are, but im not sure how to take the first scripting steps. How can i add an image with a script? How can i store a x y coordinates?
    1. I would create four variables and than store the XY cords of the the high point of the head, the bottom of the chin, amd the farthest right and left of the face.
    2. I would than add the image of the head that I would already have.
    3. If the x coordinates of the top and bottom are off kilter, I would rotate new head until = old face dimensions..
    4. I would also see if the width is too big or small and resize accordingly
    5. I would than resize the head so that the eyes would match up.
    Thanks for any help you can provide!

    Is that script for a browser html. Its not for Photoshop and like Photoshop would fine UiApp undefined so does Microsoft.  Is that a Chrome script or Android script? Why post it here?
    Atiqur Sumon wrote:
    function doGet() {
       var app = UiApp.createApplication();
       // The very first Google Doodle!
       app.add(app.createImage("http://www.google.com/logos/googleburn.jpg"));
       // Just the man in the middle
       app.add(app.createImage("http://www.google.com/logos/googleburn.jpg", 118, 0, 50, 106));
       return app;

  • How can I automate the multi-step process of looking up a caller's contact details when a telephone call comes in with caller ID?

    How can I automate the multi-step process of looking up a caller's contact details when a telephone call comes in with caller ID. I want to be able to see more than just the first & last name when a client calls me. I would like the caller ID to pull up the same information that shows up when you search for and find a contact name and then click on the right arrow.
    My workaround is to force/enter both the last name and the address in the last name field since then the address will show up.
    The only computerized way to look up this additional information is to put the client on hold, memorize the first and last name and correctly enter it in the search field of the contact database and hopefully find it before the client gets tired of waiting.
    Note that I go to about 48 small jobs per week. So far I have about 9,000 contacts. It's easy to make a mistake and have the client wondering what I'm doing and what's taking so long.
    The second workaround is to use paper and pencil and ask the client for name, address, cross street and phone number again, repeating what I did some time previously.
    Please help meautomate this process.

    You don't have to put anyone on hold. When the call comes in, tap the Home button, then tap contacts, go to the contact. Tap Home button when finished, tap the top banner to return to the call screen.

  • I have a one-column table in pages.  Each cell has text and a number separated by a colon.  Can I automatically make it two column with everything to the right of the colon in the second column?

    I have a one-column table in pages.  Each cell has text and a number separated by a colon.  Can I automatically make it two column with everything to the right of the colon in the second column?

    Here's another way that is pretty quick to do.
    Formula in Column B is:
    =LEFT(A, FIND(":", A))
    Formula in Column C is:
    =RIGHT(A, LEN(A)-FIND(":", A))
    You can eliminate the colon from the result in column B by writing:
    =LEFT(A, FIND(":", A)-1)
    Once you do the conversion, you should freeze the result by Selecting columns B and C and then Command-C, Edit > Paste Values.
    Regards,
    Jerry

Maybe you are looking for

  • ORA-12157 when installing Oracle 10g on Fedora 5?

    Hi, Im installing Oracle 10g on Fedora 5, I did it once, but when I tried to set it up again I got this error on the last part of the install... ORA-12157: TNS: internal network communication error Anybody know what might cause this? I think I have i

  • Validation of non-qualifier

    Hello experts I have a validation problem on my qualified table. From the main table, containing customers I have a qualifier called Customer Numbers. It only has one non-qualifier called organization. It represents the internal organisation at the c

  • DRQ : Warehouse Name in Bill of Material for Finished Product

    Hi The Warehouse Name is missing in the drop-down list in the header level of BOM.  It is very difficult to select the Warehouse from drop-down, if there are too many Warehouse.  Or other way to provide a Select from List functionality for Warehouse

  • Button function failure

    Why do my button functions work perfectly on my iPad2 Adobe Content Viewer the first time and then do not function at all in subsequent viewings. For example, the next page button ceases functioning after the first viewing. On page 2, the next page b

  • Lightroom cc Crop overlay issue

    When I try and use the Lightroom CC crop overlay tool I get what seems to be a rendering failure that shows as a blue box with a white cross. See attached. Computer is a Surface Pro 3 i7 with 8.1 fully updated.