• 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
Re: Do shell script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Do shell script


  • Subject: Re: Do shell script
  • From: Andrew Oliver <email@hidden>
  • Date: Tue, 14 Oct 2003 23:23:45 -0700

In order to pass filenames that contain 'special' characters to a shell
script you need to either escape the characters or quote the string.

The easiest way to do this is simply:

...
set myFileName to "AnythingGoes.txt" as Unicode text
set myFoundFiles to every paragraph of (do shell script "find " & myFolder
& " -name " & quoted form of myFileName & " -type f")

Andrew
:)

On 10/14/03 10:38 PM, "Richard Rvnnbdck" <email@hidden> wrote:

> Hello,
>
> I have been noticing some very interesting threads recently about finding
> files with the help of Shell Script. I have been trying that myself, but
> unfortunately I run into trouble when the filename contains special
> characters, such as brackets, spaces etc. and since I have *very* limited
> knowledge of Unix encodings and search strings I don't know how to deal with
> that. Does anyone know of a way to handle this?
>
>
> This works:
>
> set myFolder to alias (((path to current user folder) as string) &
> "Documents") -- in the actual script, the user chooses a folder
> set myFolder to quoted form of (POSIX path of myFolder)
> set myFolder to text 1 thru -3 of myFolder & "'" --drop final "/"
> set myFileName to "AnythingGoes.txt" as Unicode text
> set myFoundFiles to every paragraph of (do shell script "find " & myFolder
> & " -name " & myFileName & " -type f")
>
>
> This doesn't
>
> set myFolder to alias (((path to current user folder) as string) &
> "Documents") -- in the actual script, the user chooses a folder
> set myFolder to quoted form of (POSIX path of myFolder)
> set myFolder to text 1 thru -3 of myFolder & "'" --drop final "/"
> set myFileName to "AnythingGoes(Copy).txt" as Unicode text
> set myFoundFiles to every paragraph of (do shell script "find " & myFolder
> & " -name " & myFileName & " -type f")
>
>
> Nor would this
>
> set myFileName to "Anything Goes.txt" as Unicode text
> _______________________________________________
> applescript-users mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/applescript-users
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Do shell script (From: Richard Rönnbäck <email@hidden>)

  • Prev by Date: Re: open file for overwriting
  • Next by Date: Re: open file for overwriting
  • Previous by thread: Do shell script
  • Next by thread: Re: TextField to Command line
  • Index(es):
    • Date
    • Thread