• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

GREP AppleScripting InDesign removing commas

Explorer ,
Aug 08, 2019 Aug 08, 2019

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!

TOPICS
Scripting

Views

2.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Aug 09, 2019 Aug 09, 2019

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 "

Votes

Translate

Translate
Guru ,
Aug 09, 2019 Aug 09, 2019

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 "

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 12, 2019 Aug 12, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2019 Aug 13, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 13, 2019 Aug 13, 2019

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Aug 13, 2019 Aug 13, 2019

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 14, 2019 Aug 14, 2019

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Aug 14, 2019 Aug 14, 2019

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 14, 2019 Aug 14, 2019

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Aug 14, 2019 Aug 14, 2019

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Aug 14, 2019 Aug 14, 2019

Copy link to clipboard

Copied

Bye Bye ExtendScript

Bye Bye SUI

Bye Bye CEP

Hello UXP, for how long and in how long ????

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 14, 2019 Aug 14, 2019

Copy link to clipboard

Copied

Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 14, 2019 Aug 14, 2019

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 16, 2019 Aug 16, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 16, 2019 Aug 16, 2019

Copy link to clipboard

Copied

I think Applescript is easier. It also has some real advantages, even though it's not cross platform.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 18, 2019 Aug 18, 2019

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Aug 19, 2019 Aug 19, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 20, 2019 Aug 20, 2019

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines