• 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: OSX: handy handler - making backslash characters in a file path in order to pass it to the shell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OSX: handy handler - making backslash characters in a file path in order to pass it to the shell


  • Subject: Re: OSX: handy handler - making backslash characters in a file path in order to pass it to the shell
  • From: Timothy Bates <email@hidden>
  • Date: Wed, 24 Oct 2001 01:31:06 +1000

Sorry for the dumb mails: 1:30 am and I need knocking unconscious.

The handler did work properly, but this one takes care of another problem,
that of colons instead of slashes as directory delimiters

set thedrive to "332 M63"
--try
set x to mactoUnix("/Volumes/" & thedrive & "/Desktop Folder/232
questionnaire")
Shell "rm -d " & x
--end try

on mactoUnix(x) --replaces " " with "\ " and ":" with "/"
set {olddelimiters, AppleScript's text item delimiters} to
{AppleScript's text item delimiters, " "}
set x to every text item of x
set AppleScript's text item delimiters to "\\ "
set x to x as string
set {olddelimiters, AppleScript's text item delimiters} to
{AppleScript's text item delimiters, ":"}
set x to every text item of x
set AppleScript's text item delimiters to "/"
set x to x as string
set AppleScript's text item delimiters to olddelimiters
return x
end mactoUnix



Hi there,

Because the finder cannot delete network files without a dialog, I needed to
say:

Shell rm -d /VolumesDrive\ M61/Desktop\ Folder/232\ questionnaire

Where "Drive\ M61" is a disk name that varies across 40 values.

So, this handler might help someone else in the future - it strips spaces
replacing them with "\ " as the standard terminal shell requests.


on escapeSpaces(x)
set {olddelimiters, AppleScript's text item delimiters} to
{AppleScript's text item delimiters, " "}
set x to every text item of x
set AppleScript's text item delimiters to "\\ "
set x to x as string
set AppleScript's text item delimiters to olddelimiters
return x
end escapeSpaces

--an example of usage is

set thedrive to "Drive M61"
set x to escapeSpaces(thedrive & ":C4A332WORKSTATIONS:untitled:")
Shell "ls " & x


> Tim


References: 
 >OSX: handy handler - making backslash characters in a file path in order to pass it to the shell (From: Timothy Bates <email@hidden>)

  • Prev by Date: OSX: handy handler - making backslash characters in a file path in order to pass it to the shell
  • Next by Date: Re: Scaling large images w/ Akua Sweets
  • Previous by thread: OSX: handy handler - making backslash characters in a file path in order to pass it to the shell
  • Next by thread: Quark (mainly) + FileMaker Pro kafuffle
  • Index(es):
    • Date
    • Thread