Skip to main content
Inspiring
June 24, 2020
Answered

Save all open files with truncated file names

  • June 24, 2020
  • 2 replies
  • 701 views

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!

 

This topic has been closed for replies.
Correct answer Manan Joshi

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

2 replies

Manan JoshiCommunity ExpertCorrect answer
Community Expert
June 24, 2020

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

-Manan
Inspiring
June 24, 2020

That's it!! THANK  YOU!

Community Expert
June 24, 2020

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

-Manan
Inspiring
June 24, 2020

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.