• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Editing a shell included in Bundle contents
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Editing a shell included in Bundle contents


  • Subject: Re: Editing a shell included in Bundle contents
  • From: Jay Louvion <email@hidden>
  • Date: Tue, 11 Oct 2005 14:39:26 +0200

Title: Re: Editing a shell included in Bundle contents

On Oct 11, 2005, at 4:11 AM, Jay Louvion wrote:


 Now this seems to be a bit of a brain teaser, but it might seem a stroll in the park to some of you... So:
 
 I’ve got an application bundle written in AS that alllows me to convert most films into mpg2 films. I use it in drag ‘n’ drop. I call a do shell using a shell command included in the bundle, thus:

set convert_shell to (quoted form of (POSIX path of ((path to me as text) & "contents:resources:loud_convert")))
 set thecline to (convert_shell & " " & POSIX_path & " " & ConvertedFilmsPath)
 do shell script thecline
 
That’s fine when the shell (loud_convert) doesn’t need to have an extra resource. But if I want to use an extra resource such as a silent audio track (to have a muted film), the shell (mute_convert) needs to be edited. Is there a way to edit a bundle resource on the fly ? If so a working example would be much more precious than a simple “yes”... :-)

-----------


On 11/10/05 13:31, "Neil Faiman" <email@hidden> wrote:

It would seem to me that the easiest solution to your problem would be to adjust the boundaries between the AppleScript part of your solution and the shell script part of a solution, just a little bit. You want to write the shell script so that it doesn't need to be edited, and so that all the variability is in the AppleScript.

Being slightly more  concrete, I believe that you want to write your shell scripts  so that everything that might need to be changed by the AppleScript is represented as a parameter rather than as a hard-coded string. Then the AppleScript needs to determine the correct value of the parameter at runtime, and pass it as an additional argument in the "do shell script" command string.

In your  particular case, I believe that the result would look something like this (and I'm not being very specific, because I haven't personally worked with AppleScript bundles):

In the shell script:

function convertFile() {
    /opt/darwinports/bin/ffmpeg -y -i "$3" -i "$1" \
            -target pal-dvd -aspect 4:3 -acodec mp2 -ab 128a \
            -vcodec mpeg2video -b 3000 -g 25 "$2"
}

convertFile "$1" "$2" "$3"


In the AppleScript:



set
convert_shell to (quoted form of (POSIX path of ((path to me as text) & "contents:resources:loud_convert")))
set SilencePath to (quoted form of (POSIX path of ((path to me as text) & "contents:resources:silence.mp2")))
set thecline to (convert_shell & " " & POSIX_path & " " & ConvertedFilmsPath & " " & SilencePath)
do shell script thecline

Regards,

    Neil Faiman

--------

Wonderful ! Works like a charm and gives me more insight into how shell scripts (and thanks to you, Mark JR ;-) work.
Mmh...feels like a job well done.

J.

Jay Louvion
Studio Casagrande
3, rue Müller-Brun
1208 Geneva

T+4122 840 3272
F+4122 840 3271

skypeme:
jaylouvion

www.studiocasagrande.com

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Editing a shell included in Bundle contents (From: Neil Faiman <email@hidden>)

  • Prev by Date: Re: Editing a shell included in Bundle contents
  • Next by Date: Re: recursion depth
  • Previous by thread: Re: Editing a shell included in Bundle contents
  • Next by thread: Re: Editing a shell included in Bundle contents
  • Index(es):
    • Date
    • Thread