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

Action that copies file to folder based on page count

New Here ,
Dec 17, 2024 Dec 17, 2024

Copy link to clipboard

Copied

Hi all! - got a little scenario I need help solving, hoping some of you clever minds can help me!

I have a bundle of files that will be delivered to me each week, these will be varying in page count from:
34, 36, 38 & 40 pages (possibly more havent been told yet).

I need these split into seperate folders based on the page count... Ideally I don't want to be doing this manually, opening each oneindividually, checking page count, then dragging over to a folder...

I have an action set up for these already as pages need rotating, flattening ect, so my ideal outcome is to have some javascript that will execute as part of this workflow inside this action. It would count the pages, and move to a folder located on my mac. 

Not sure if this is possible, couldn't find much online! Thanks for the help in advanced!

TOPICS
How to , JavaScript

Views

138

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
1 ACCEPTED SOLUTION
Community Expert ,
Dec 17, 2024 Dec 17, 2024

Copy link to clipboard

Copied

Sorry, I forgot the quotes (now corrected).  It should be:

this.saveAs("/Volumes/ClientFolder/Client1/TestFolder/" +"Page_"+ this.numPages+ "/"+this.documentFileName);

View solution in original post

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 ,
Dec 17, 2024 Dec 17, 2024

Copy link to clipboard

Copied

In this example, assume your folders are named Pages_34, Pages_36, etc.  In your action add "Execute JavaScript" as the last command then add the following script:

this.saveAs("/*this is the file path to your folder including the last slash*/ " + "Page_" + this.numPages + "/" + this.documentFileName);

If you're folders aren't consistently name and/or don't have the number of pages in the name you will have to create an if statement like this:

var fldrName;

if(this.numPages==36)

{fldrName="The first folder"} else

if(this.numPages==38)

{fldrName="The second folder"} else...etc.

Then pass the variable into the saveAs cPath parameter.  I'm not a Mac user but I believe the file paths us backslashes.  Open a PDF in one of the folders and run the following script in the console to see the path structure then escape backslashes in your script if the paths contain them:

this.path

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
New Here ,
Dec 17, 2024 Dec 17, 2024

Copy link to clipboard

Copied

Screenshot 2024-12-17 at 12.31.33.png

 Thanks for the response! I have added this to the Execute Javascript function, its not allowing me to click ok - says there is a syntax error - am I missing something?

Sorry 0 knowledge of code here... 

Appreciate the help!

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 ,
Dec 17, 2024 Dec 17, 2024

Copy link to clipboard

Copied

Sorry, I forgot the quotes (now corrected).  It should be:

this.saveAs("/Volumes/ClientFolder/Client1/TestFolder/" +"Page_"+ this.numPages+ "/"+this.documentFileName);

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
New Here ,
Dec 17, 2024 Dec 17, 2024

Copy link to clipboard

Copied

This is perfect thank you so much, you have just saved me a bunch of time! I take it if a file has more pages and there is no folder setup, it will just skip this file?

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 ,
Dec 17, 2024 Dec 17, 2024

Copy link to clipboard

Copied

You can do this:

try{this.saveAs("/Volumes/ClientFolder/Client1/TestFolder/" +"Page_"+ this.numPages+ "/"+this.documentFileName);}catch(e){console.println(this.documentFileName)}

Open the console when the Action is finished and it will show a list of files that weren't saved (if any).

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
New Here ,
Dec 17, 2024 Dec 17, 2024

Copy link to clipboard

Copied

LATEST

Thanks! You have been a lot help, really appreciated!

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