• 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: Scripting Additions: Embracing the Horror of Unix
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting Additions: Embracing the Horror of Unix


  • Subject: Re: Scripting Additions: Embracing the Horror of Unix
  • From: "J.B. Stewart" <email@hidden>
  • Date: Wed, 30 Jan 2002 16:58:00 -0500

On 1/30/02 16:01, "Shane Stanley" <email@hidden> enscribed:

> On 31/1/02 6:25 AM +1000, Paul Berkowitz, email@hidden, wrote:
>
>> I guess I'd settle for unix-y ones until somebody came up with a
proper
>> AS-type osax later on, but that way lies messiness.
>
> Well, it looks like you don't need to worry. All the unix experts seem
to
> agree that the file commands in Jon's can be done using do shell
script, for
> example, but not one of them seems willing to actually spell out how,
> despite repeated hints...

Well I'm no unix expert but sometimes I just can't resist a challenge or
hint. The script below copies a file from one place to another and
preserves the resource fork of the file.

While I was writing this I discovered that the "POSIX path" property (of
POSIX File) from Standard Additions (AS 1.8.2b1) didn't handle spaces in
file names so there is a handler at the end of the script to "escape"
spaces in the path name. The "POSIX path" property also didn't seem to
care for aliases to files hence the coercion to string paths.

The script uses the Unix "ditto" command to execute a shell script. It
doesn't look too much like Unix does it? On the other hand, the script I
use to re-boot into OS 9 most definitely looks like Unix. The hardest
part of all this (for me) seems to be knowing the Unix command exists in
the first place.

John

set srcFile to ((choose file with prompt "Please select the file to
copy") as string)
set destDir to ((choose folder with prompt "Please select the
destination directory.") as string)

if srcFile contains " " then
set srcFile to my fixSpc(srcFile)
end if

if destDir contains " " then
set destDir to my fixSpc(destDir)
end if

do shell script "ditto -rsrcFork " & POSIX path of srcFile & space &
POSIX path of destDir

(* this isn't fully tested with multiple spaces in various portions of a
file's path *)
on fixSpc(pth)
set {oldDelims, AppleScript's text item delimiters} to
{AppleScript's text item delimiters, {" "}}
set tmp to every text item of pth
set AppleScript's text item delimiters to {"\\ "}
set pth to items of tmp as string
set AppleScript's text item delimiters to oldDelims
return pth
end fixSpc


  • Follow-Ups:
    • Re: Scripting Additions: Embracing the Horror of Unix
      • From: garbanzito <email@hidden>
    • Re: Scripting Additions: Embracing the Horror of Unix
      • From: John W Baxter <email@hidden>
    • Re: Scripting Additions: Embracing the Horror of Unix
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Newbie Question- OSX, Finder, Illustrator
  • Next by Date: Open for Access, Alias, Items in use
  • Previous by thread: RE: Scripting Additions: Embracing the Horror of Unix
  • Next by thread: Re: Scripting Additions: Embracing the Horror of Unix
  • Index(es):
    • Date
    • Thread