How to duplicate a PDF document

scorpio_33
Newbie
Posts: 7
Joined: Tue Nov 16, 2010 11:11 pm

How to duplicate a PDF document

Post by scorpio_33 »

Is there any way to duplicate the entire PDF document? I need to perform n copies of the information stored in the document name. For example:



name_n.pdf



where:

name - the name of the file

n - number of copies



Does anyone have such a flow can either give me a hint how to do it?
gfloro
Newbie
Posts: 10
Joined: Tue Oct 19, 2010 5:20 pm

How to duplicate a PDF document

Post by gfloro »

I think this would have to be accomplished through a script.
scorpio_33
Newbie
Posts: 7
Joined: Tue Nov 16, 2010 11:11 pm

How to duplicate a PDF document

Post by scorpio_33 »

I know but how?
gfloro
Newbie
Posts: 10
Joined: Tue Oct 19, 2010 5:20 pm

How to duplicate a PDF document

Post by gfloro »

If you don't need to use Switch, you could create an Automator Workflow or an AppleScript to run the Finder's Duplicate command on the file n number of times.



Example AppleScript:

display dialog "How many times do you want the duplicator to run?" buttons {"Cancel", "OK"} default button "OK" default answer ""

set the_loops to text returned of the result as number

tell application "Finder"

repeat the_loops times

duplicate selection

end repeat

end tell


The problem with that though is [1] it requires user input, how many times to duplicate the file and [2] the file name has the word "copy" added.



I am by no stretch of the imagination a "scripter", but a JavaScript that you add to your flow would:



1. set a bunch of variables, ie. input file name, input and output directories

2. grab the count value from the file name and assign to a variable

3. run loop statement to:

- copy the original file to a output directory, rename it

- repeat until it reaches the count value



Simple ;-)



Hopefully that's somewhat helpful.
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

How to duplicate a PDF document

Post by dkelly »

Hello, I created a Script Element that implements a file duplicate function. There's a single property for the number of copies to create.



download FileDup script



Enjoy,

Dwight Kelly

Apago, Inc.
scorpio_33
Newbie
Posts: 7
Joined: Tue Nov 16, 2010 11:11 pm

How to duplicate a PDF document

Post by scorpio_33 »

Many, many thanks for all. Thank You.
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

How to duplicate a PDF document

Post by dkelly »

Did you end up using the AppleScript or Switch script solution?
scorpio_33
Newbie
Posts: 7
Joined: Tue Nov 16, 2010 11:11 pm

How to duplicate a PDF document

Post by scorpio_33 »

Switch script soliution. Thank You for Your help.
gfloro
Newbie
Posts: 10
Joined: Tue Oct 19, 2010 5:20 pm

How to duplicate a PDF document

Post by gfloro »

Dwight,



Nice solutions, thanks for posting. It's nice to see some real world scripting examples to help learn from.



I was going to try modifying your script, so I can use SwitchClient to set the copies, but was stuck on the syntax for getting the metadata from the jobs internal job ticket. Can you offer suggestions?



Gregory
diwu
Newbie
Posts: 8
Joined: Tue Nov 23, 2010 3:50 pm

How to duplicate a PDF document

Post by diwu »

Hi Gregory,



You got stuck on getting the metadata from the job. Does this mean you were able to change the script and add a property editor "single-line text with variable" for the copies property?



If you modified the script like this you should be able now to use metadata from SwitchClient.



When you use the updated script in PowerSwitch make sure you have a sample job somewhere in your flow.

I suggest you submit a file via Client with the number of copies as metadata and put a connection on hold somewhere before the duplicate script.

Stop the flow, go to the duplicate script and set the copies property to define single-line text with variable. Choose metadata - text - build location path. Select the external dataset (by default this should be "Submit") and browse the data tree to set the location path for the number of copies you entered in Client.



That should do.

I also created this sample flow



kr,

Dieter
gfloro
Newbie
Posts: 10
Joined: Tue Oct 19, 2010 5:20 pm

How to duplicate a PDF document

Post by gfloro »

Dieter,



I haven't actually modified Dwight's script as yet. I was going through the documentation looking for what I would need to add to the script to get this working with Client. I'll try your advice and test flow and report back.



Thanks.



Gregory
gfloro
Newbie
Posts: 10
Joined: Tue Oct 19, 2010 5:20 pm

How to duplicate a PDF document

Post by gfloro »

Dieter,



I followed your instructions, modified Dwight's script and my Flow and got it working. I learned something new.



Cheers,

Gregory
scorpio_33
Newbie
Posts: 7
Joined: Tue Nov 16, 2010 11:11 pm

How to duplicate a PDF document

Post by scorpio_33 »

Hello again



How can I modify the script to duplicated files have been uploaded to a folder, named like duplicated file? In next step I would like to combine pdf files but to do so they must be in a folder not than separately.
gfloro
Newbie
Posts: 10
Joined: Tue Oct 19, 2010 5:20 pm

How to duplicate a PDF document

Post by gfloro »

Use the SwitchScripter application to modify the script. Try using the "Assemble Job" connector to gather the PDFs to send to Acrobat. Then use the merge option for Acrobat.
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

How to duplicate a PDF document

Post by dkelly »

diwu wrote: Hi Gregory,

Does this mean you were able to change the script and add a property editor "single-line text with variable" for the copies property?




Hi, my original script has a property for the number of copies. Why do you state that another needs to be added?
Post Reply