Jump to content

Pattern matching in applescript

1 post in this topic

Recommended Posts

Hello everyone!  I'm new to this forum .. so Hello once again :)


Question 1:


How do I do the following from within applescript so I can speed up the runtime (I run the below 1000s of times)

set output to do shell script "echo \"" & image_file & "\" | egrep  '.JPG|.jpg|.JPEG|.jpeg|.PNG|.png' "

Question 2:


I have other shell commands (e.g. myscript.pl -file  '<file_name>').  But the file name also contains spaces and 's.  Is there a way to get applescript to automatically insert the appropriate escape characters for 's ?  Using "quoted form of" doesn't work.

display dialog "echo '" & mytext & "'"
display dialog "echo '" & quoted form of mytext & "'"

-- manual escape characters into the mytext.  I want it to put the escape characters automatically.
display dialog "Why doesn't it print: " & "echo '" & "It\\'s cool' "

Question 3:


I don't mind skipping the above command on files that contain '.   How do I match a ' in a string from within applescript?


Link to comment
Share on other sites


  • Create New...