• 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
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]

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


  • Subject: 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:15:50 +1000

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


  • Follow-Ups:
    • Re: 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: fleeting help menu?
  • Next by Date: Re: OSX: handy handler - making backslash characters in a file path in order to pass it to the shell
  • Previous by thread: Re: fleeting help menu?
  • Next by thread: Re: OSX: handy handler - making backslash characters in a file path in order to pass it to the shell
  • Index(es):
    • Date
    • Thread