hi,
i’m trying to use the rm shell script to delete a user determined file (selected from a list) the problem is that some files have spaces in them, and that messes things up (its seen as two commands). any ides? i don’t really know terminal commands, is there a way to make it ignore spaces? or is there a replacement character? if so how to i make applescript replace all spaces it a string with the replacement character?
thanks in advance.
[b]Edit[b]ok, so i found out that you need to put a backslash before any spaces, is there a easy way to do this with as?
ok, sorry about spamming this forum, this is what i wrote to add backslashes before spaces, is this the easiest way?
set thestring to "hi my name is joe"
set ditd to text item delimiters
set res to missing value
set text item delimiters to " "
repeat with tis in text items of thestring
if res is missing value then
set res to tis
else
set res to res & "\\ " & tis
end if
end repeat
set text item delimiters to ditd
display dialog res
do shell script "rm " & quoted form of theFile
-- This will delete a file from you're home folder
choose from list {"test quoted form.txt"}
do shell script "rm " & quoted form of ("~/" & result)
while i’m at it, i ounce wrote a whole big script to format numbers (make 1234567.8910 into 1,234,567.89) is there by any chance a one line command for that too?
Save a blank file, put an apostrophe in the name, and try this:
choose file without invisibles
do shell script "rm " & quoted form of POSIX path of result
If you enclose the path with double quotes instead of single, you could have problems with dollar signs, because the shell will interpret them as variables.