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

Activate open document by name using wildcard for the document name

Engaged ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

Hello,

I want to activate an open document by name.

The document  name always  start with "small_", ends with  different number for 1 to 31, extension .pdf

For example today opened document is "small_18.pdf"

There is a way to activate it by name using wildcard, eg "small_*" ?

 

TOPICS
Scripting

Views

356

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

Community Expert , Nov 18, 2020 Nov 18, 2020

Try the following

for(var i = 0; i < app.documents.length; i++)
{
	var fName = app.documents[i].name
	if(fName.match(/small_\d+\.pdf/))
	{
		app.activeDocument = app.documents[i]
		break;
	}
}

-Manan

Votes

Translate

Translate
Adobe
Guide ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

What if there is more than one open document starting with "small_"?  Which should become active then?  

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
Engaged ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

Always there is only one open document starting with "small_"

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 ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

The question is not clear, do you mean to say there are lots of document open and want the script to activate the first document that matches your criteria? Why can't this be done manually, how will a script help?

-Manan

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
Engaged ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

Always there is only one open document starting with "small_x"
Usage example
The user open the "small_x.pdf" document

Then opens about ten or more documents

At every one of other documents, the user make a path selection

The script makes a copy of the selection, close the document, activates the "small_x.pdf" , and paste it

I hope it is clear now!

 

 

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 ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

Try the following

for(var i = 0; i < app.documents.length; i++)
{
	var fName = app.documents[i].name
	if(fName.match(/small_\d+\.pdf/))
	{
		app.activeDocument = app.documents[i]
		break;
	}
}

-Manan

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
Engaged ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

LATEST

It is perfect,

thank you!

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