Re: do shell script "sort" not working
Re: do shell script "sort" not working
- Subject: Re: do shell script "sort" not working
- From: "Mark J. Reed" <email@hidden>
- Date: Wed, 9 Nov 2005 09:53:38 -0500
On 11/9/05,
pete boardman <
email@hidden> wrote:
set sort_script to ("cat " & quoted form of ImagesUsed_POSIX & " | tr
\"\\015\" \"\\012\" | sort -o " & quoted form of Imagessorted_POSIX)
Minor tip: "cat file | blah" is never necessary; you can just do "blah
<file" - or even "<file blah" if you prefer to put the file
first. Most commands that you're liable to pipe a file through to
something else will also take the file as an argument, so you don't
need the "<" if you put the filename after the command. The tr
command is one such, so you can also do "tr 'fromchars' 'tochars'
filename".
(- I use the octal codes for CR and LF because using "\r" and "\n"
looks odd when compiled.)
You can let tr decode the escapes instead of AppleScript; then they
don't get decompiled. I find '\r' and '\n' more legible than the
octal numbers:
set sort_script to "tr '\\r' '\\n' " & quoted form of ImagesUsed_POSIX & " | sort -o " &
quoted form of ImagesSorted_POSIX
(I used 'quoted form' because I tried it on a folder called "untitled
folder" - space prevented it from running...)
Yup. Without the quotes, "sort untitled folder" is a command with
two arguments, "untitled", and "folder", which sort will look for as
filenames, and complain and do nothing if they can't be found.
(If both files can be found, it sorts them together). Although
sort will also fail on 'untitled folder' if it really is a folder; it
can't sort one of those. :)
--
Mark J. Reed <
email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden