• 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: Bash to AppleScript? (Is this possible to do with AS?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash to AppleScript? (Is this possible to do with AS?)


  • Subject: Re: Bash to AppleScript? (Is this possible to do with AS?)
  • From: "Mark J. Reed" <email@hidden>
  • Date: Fri, 21 Dec 2007 07:17:39 -0500

No comment on the AS translation yet, but I do have some observations about the bash version..

On Dec 21, 2007 3:56 AM, Scott Wilcox <email@hidden> wrote:
# Bash script to process iTunes artwork and then move
# new images over to webserver.

You should probably put a shebang line (#!/bin/bash) as the first thing in the script so you can run it as a command..

# First, clean out old path (just to make sure nothing is left there)
/usr/bin/rm -rf /tmp/albumart/*

That's a little scary.  Maybe a check to make sure a copy of the script isn't currently running before you do that?
 
# Now find all the new albumart .itcs
find /Users/scott/Music/iTunes/Album\ Artwork/ -name *itc* -exec
/usr/bin/java jpegextractor -D /tmp/albumart -d 4 -q -p album {} \;

1. I don't know what other files are in the Album Artwork folder, but if you really want just the itc ones you should use -name '*.itc' instead of '*itc*', which matches e.g. "The Bitch is Back (Elton John's Greatest Hits)"

2. calling "/usr/bin/java jpegextractor" like that forces you to be in a certain directory when you run the script.  Might want to consider putting the full path to the class (preferably set as a parameter at the top of the script where you can easily change it later).

3.  Is the jpegextractor Java class one you wrote?   Will it take more than one filename at a time as arguments?  Firing up a new copy of the JVM for every file feels inefficient to me; if jpegextractor takes more than one, you could replace the -exec ... {} \; with -print | xargs ...


# Now, use Imagemagick to resize all the images to a
# size we'd like to use
/usr/local/ImageMagick-6.3.7/bin/mogrify -resize 100x100 /tmp/albumart/*

That will fail for a large number of album covers (or if there are enough with really long filenames).  You  might want to use

find /tmp/albumart  -name '*.jpg' | xargs mogrify -resize 100x100

 
# Now we need to scp the albumart over to our webserver
/usr/bin/scp /tmp/albumart/* www@iaso:/a/path/on/server

I'd recommend using rsync instead; that way  only the images that have changed will get copied.

In fact, it seems like you're potentially repeating a lot of work when you run this script.  Perhaps you could keep a local copy of the 100x100 jpegs on your hard drive permanently, rather than in a temp folder that gets deleted between runs?  Then you'd have a basis for comparison to identify those album covers you haven't processed yet, and only do those.

Also SCP requires a password being entered with no method of caching,
this is a bit of a pain, without setting up keys not avoidable -
anything applescript side that can help here?

So what keeps you from setting up ssh keys?  (rsync will use them, too.)  As for AS help, see the other thread on scripting the keychain ("remember in keychain" is the subject line, IIRC).

--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: How to start/restart the Finder from an AS app? (From: "Stockly, Ed" <email@hidden>)
 >Re: How to start/restart the Finder from an AS app? (From: Christopher Nebel <email@hidden>)
 >Re: How to start/restart the Finder from an AS app? (From: "Mark J. Reed" <email@hidden>)
 >Re: How to start/restart the Finder from an AS app? (From: Philip Aker <email@hidden>)
 >Bash to AppleScript? (Is this possible to do with AS?) (From: Scott Wilcox <email@hidden>)

  • Prev by Date: OS X, 10.1 and Above - Append PDF files Using Applescript
  • Next by Date: Re: sysv and OS X 10.4.10 and .11
  • Previous by thread: Re: Bash to AppleScript? (Is this possible to do with AS?)
  • Next by thread: Re: How to start/restart the Finder from an AS app?
  • Index(es):
    • Date
    • Thread