These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Rename or Delete File using javascript in Batch processing

transient101
Registered: Oct 15 2009
Posts: 4

I have batch sequence that ocr pdfs at the same location (to keep the directory structure intact). If I setup a batch to append text string to the filename then it will create a new file and I can’t get batch setup to overwrite the original file with different name. I want only one pdf file after batch execution.

Is there anyway to rename or delete the file using javascript in batch processing under Acrobat-9 Pro ?

Any help would be appreciated.

My Product Information:
Acrobat Pro 9.1.3, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Nope.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

transient101
Registered: Oct 15 2009
Posts: 4
It sucks.
They allow saveAs() method but not save(). You can delete pages but not the document. There is a documentFileName property of document class but no setter method. I don't understand, why can't they allow this? Are there any workarounds?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You can file a feature request here: https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
But I seriously doubt it will change anything as the trend has been that with each new version there are more and more security restrictions, not less.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

danny28
Registered: Oct 28 2009
Posts: 2
I am not sure if this is the samething but i am new and needing help. I had made a bath and ran it with a footer. Now I am trying to over ride that batch and it is not working. Also I have been trying to figure out how to do a batch with a java scrpit in it. I have been doing this on Work Instructions, Procedures, and many other libaries that we have. I only have Adobe Prof. 7. If any one can help that would be great.
FruitCake
Registered: Aug 10 2010
Posts: 4
I am also looking for a solution to this problem. I want to delete an old file that I just modified and saved as a new file with a new file name.

Currently, I am dropping an annotation into the old file before I create the new file. Later, with OS level scripts, I can find the annotated files and delete them.

Miserable work around, I say.

Does anyone know if we can point an Acrobat Javascript to a custom library that has been compiled with functionality to interact with the file system? For example, can I connect to a custom library that contains a "delete file" functionality?

For example, can I create such a function in an Acrobat Plug-in, and then access the plug-in with a function call from a document or folder Acrobat Javascript?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Acrobat JavaScirpt is sand boxed for some very good security reasons. There are also restrictions non silent printing and silent saving.

George Kaiser

FruitCake
Registered: Aug 10 2010
Posts: 4
Two things in response to latest comment:

1) So you don't think that a call to an external library is possible? or that calls to external libraries are possible but there is some subtle mechanism in Javascript that senses an attempt to perform a file system operation?

2) With respect to the sandboxing, people on other forums observe that there is already a solid security net created with the concept of "privileged" operations. They continue by observing that there is a solid mechanism established to give pathways through the security net with the concept of trusted functions. Why can't file system operations be allowed through trusted functionality? In fact, "saveAs" is allowed as a trusted function. This is a file system operation.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Yes, you can write a plug-in with C++ if you want.

Being able to delete or rename files has never been part of Acrobat JavaScript since it was introduced with version 4 of Acrobat. You can use [url=https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform]Feature Request/Bug Report Form[/url] to ask Adobe to consider it.

Adobe has been tightening security with each new version, so I expect the next version to be even tighter.

George Kaiser

try67
Expert
Registered: Oct 30 2008
Posts: 2398
@FruitCake

1) No. But let us know if you are able to do it...

2) Save As is not a file-system operation. It's an operation within Acrobat, and even that has strict limitaitons when executed with a script. Adobe has decided to limit the possibilities of JavaScript within Acrobat to protect the users and prevent potential viruses, I would imagine. See the mess that Macros in Office applications can cause. In newer versions of Office macros can only be used in special file formats and are disabled by default. So I don't think there's a chance this will change in the direction you describe. If anything, it will become more tight.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com