Copy link to clipboard
Copied
I'm writing an AppleScript to remove extra commas from certain letter combinations using GREP. I'm searching for this combination of letters and numbers:
), 60W,
), 100W,
(There's spaces before and after the 60W and the 100W)
This GREP seems to work for the "FIND WHAT"
\), \d\d[\l\u], |\), \d\d\d[\l\u]
In the "CHANGE TO" field, how can I delete just the commas as a GREP? I want the result to be:
) 60W
) 100W
Basically, how can I remove commas from what is returned in the "FIND WHAT" search and replace with that same text minus the commas?
Any help will be greatly appreciated!! Thanks!
Is the problem with find the grep or changing it?
If the problem is finding it you probably need to escape the grep
\\), \\d\\d[\\l\\u], |\\), \\d\\d\\d[\\l\\u]
instead of
\), \d\d[\l\u], |\), \d\d\d[\l\u]
Post your applescript here if it doesn't work
Try a really simple grep and see if that does work.
Something like find "e"
If the problem is change to you need to use brackets
Find
(\\)),( \\d{2,3}[\\l\\u]),
Replace
"$1$2 "
Copy link to clipboard
Copied
Is the problem with find the grep or changing it?
If the problem is finding it you probably need to escape the grep
\\), \\d\\d[\\l\\u], |\\), \\d\\d\\d[\\l\\u]
instead of
\), \d\d[\l\u], |\), \d\d\d[\l\u]
Post your applescript here if it doesn't work
Try a really simple grep and see if that does work.
Something like find "e"
If the problem is change to you need to use brackets
Find
(\\)),( \\d{2,3}[\\l\\u]),
Replace
"$1$2 "
Copy link to clipboard
Copied
Thanks for the help, Trevor. Sorry for the delay in responding, I was out of town for a few days. I'll test your suggestions when I'm at work tomorrow, but the issue is changing the GREP. Finding it seems, to work okay.
Copy link to clipboard
Copied
jimd97292894 wrote
... the issue is changing the GREP. Finding it seems, to work okay.
Yes, and that's why Trevor says you need those brackets in the Find expression, so you can replace the text with the found text but sans commas.
Copy link to clipboard
Copied
It worked!! Thank you Trevor and Jongware!! I'm new at AppleScripting InDesign and this forum is unbelievably helpful!! I can't thank you enough!
Here's the final code I ended up using:
tell application "Adobe InDesign CC 2019"
set find grep preferences to nothing
set change grep preferences to nothing
set find what of find grep preferences to "(\\)),( \\d{2,3}[\\l\\u]),"
set change to of change grep preferences to "$1$2"
change grep
set find grep preferences to nothing
set change grep preferences to nothing
end tell
Copy link to clipboard
Copied
Glad you got it working.
You should port the script to Javascript, applescript in indesign doesn't have a future by the looks of things.
Your questions will also get answered more with js, most people ignore all questions on applescript
Copy link to clipboard
Copied
Trevor: "Applescript in InDesign doesn't have a future by the looks of things" – What do you mean by this? Thx
Copy link to clipboard
Copied
Extendscript is going to have a major update and brought to modern standards that I think will be maintained i.e. as new standards appear in JS they will be added.
The system is UXP the XD is using which works very differently from the current system, including very different UI methods.
How much of the overall API is going to remain open to COM and applescript is somewhat questionable but the new method is going to be way more efficient than anything applescript can offer
Copy link to clipboard
Copied
Interesting. Do you happen to know where I can read more about this change, or the relevant search terms? Thx
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Bye Bye ExtendScript
Bye Bye SUI
Bye Bye CEP
Hello UXP, for how long and in how long ????
Copy link to clipboard
Copied
Thanks!
Copy link to clipboard
Copied
Hi, Erin F said to stay tuned for her blog post on UXP next week at Tech Blog, (link: https://medium.com/adobetech) medium.com/adobetech , and not to start worrying about Applescript in InDesign yet if that's all we support. Also, scripting is safe as far as she knows, and she doesn't imagine that would change on the Adobe side. (paraphrasing)
Copy link to clipboard
Copied
Interesting. I just started learning AppleScript because it seemed like it was easier to learn than JavaScript. I guess I'll start busting out the JS books.
Copy link to clipboard
Copied
I think Applescript is easier. It also has some real advantages, even though it's not cross platform.
Copy link to clipboard
Copied
Hi AS Scripter​,
There's no doubt about it.
I think Applescript is easier. It also has some real advantages.
But Applescript is much too slower than JavaScript.
I've worked with both(Applescript & JavaScript as well as), I've found that same code in Applescript takes nearly 1 min & hardly 10 seconds in JavaScript (with same loop & same execution).
Best
Sunil
Copy link to clipboard
Copied
I personally find js way easier and quicker to write than applescript which is such a verbose and clumsy language.
Yes applescript is more English like and easier for a program language illiterate to read but after a really short time it should become significantly quicker to program in js.
Copy link to clipboard
Copied
Programmers are often disdainful about Applescript, that is true. But in my experience most people find it easier for "monkey-see monkey-do" scripting and modifications of existing scripts for their own use. Casual users may not be able to even get started with JS. And multi-application scripting is much easier in my opinion. For example, using a file path and text from a database, open a photo, perform adjustments, save it elsewhere with a new name, place it into InDesign, add the text from the database, format it, PDF it, and attach that PDF to an email isn't that difficult with one script in AS. Most Mac apps are Applescriptable, but many are not javascriptable. So I think it depends on what your abilities are, how much time you have, and what you need to do.