OSX: handy handler - making backslash characters in a file path in order to pass it to the shell
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