Highlighted

Save all open files with truncated file names

Explorer ,
Jun 24, 2020

Copy link to clipboard

Copied

I need a script (i'm not a coder!) to save all open files except I need to truncate the file names. Example: I have several files with alpha-numeric filenames such as "012345_Draft.indd". I need to save all of them to a new filename with the "_Draft" removed so I end up with "######.indd" (using the original numeric portion of the filename)  for all open documents. is this possible? Please help!

 

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Try the following, it should work

var doc = app.documents
for(var i = 0; i < doc.length; i++)
{
	var path = doc[i].fullName.fsName.replace(/_Draft.indd$/,".indd")
	if(path != doc[i].fullName.fsName)
		doc[i].saveACopy(path)
}

 

-Manan

TOPICS
Scripting

Views

86

Likes

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

Save all open files with truncated file names

Explorer ,
Jun 24, 2020

Copy link to clipboard

Copied

I need a script (i'm not a coder!) to save all open files except I need to truncate the file names. Example: I have several files with alpha-numeric filenames such as "012345_Draft.indd". I need to save all of them to a new filename with the "_Draft" removed so I end up with "######.indd" (using the original numeric portion of the filename)  for all open documents. is this possible? Please help!

 

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Try the following, it should work

var doc = app.documents
for(var i = 0; i < doc.length; i++)
{
	var path = doc[i].fullName.fsName.replace(/_Draft.indd$/,".indd")
	if(path != doc[i].fullName.fsName)
		doc[i].saveACopy(path)
}

 

-Manan

TOPICS
Scripting

Views

87

Likes

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
Jun 24, 2020 0
Adobe Community Professional ,
Jun 24, 2020

Copy link to clipboard

Copied

You could use a file renaming utility for this, google should come up with some results. One such collection for windows is given below

https://www.geckoandfly.com/27387/batch-rename-files/

 

I think Adobe Bridge can also do it, i have not used Bridge personally but if you use you can investigate it.

 

-Manan

Likes

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
Reply
Loading...
Jun 24, 2020 0
Explorer ,
Jun 24, 2020

Copy link to clipboard

Copied

thank you but it's not what i'm after. I need to perform this operation from InDesign; the next step in this process is to save all open files as PDFs which I already have a script for. 

Likes

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
Reply
Loading...
Jun 24, 2020 0
Adobe Community Professional ,
Jun 24, 2020

Copy link to clipboard

Copied

Try the following, it should work

var doc = app.documents
for(var i = 0; i < doc.length; i++)
{
	var path = doc[i].fullName.fsName.replace(/_Draft.indd$/,".indd")
	if(path != doc[i].fullName.fsName)
		doc[i].saveACopy(path)
}

 

-Manan

Likes

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
Reply
Loading...
Jun 24, 2020 0
Explorer ,
Jun 24, 2020

Copy link to clipboard

Copied

That's it!! THANK  YOU!

Likes

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
Reply
Loading...
Jun 24, 2020 0