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