AppleScript do shell script find & replace in directory

45 Views Asked by At

I’ve already got a fully AppleScript find & replace script but since unix tends to be less process intensive, I’ve been trying to see if there’s a better way to script find & replace for a directory.

Set myFind to “string.to.find”
Set myReplace to “new.string”


Tell application “Finder” to set myPath  to the POSIX path of (target of front window as alias)

Do shell script (“echo myTarget = “ & myPath)

—// this is where I fall down 

Do shell script “grep -l “ & myFind & space & myPath & “ | xargs sed -i ‘s/“ & myFind & “/“ & myReplace &  “/g”


I’m not set on this code, if there’s a simpler better way to change multiple files in the target folder with the simple info of Path Find Replace

Id be very happy to be put right

Thanking you In advance

0

There are 0 best solutions below