Jump to content

Pattern matching in applescript


  • Please log in to reply
No replies to this topic

#1
apple_user_

apple_user_

    InsanelyMac Protégé

  • Members
  • Pip
  • 1 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?

 







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy