Organizing Files

Post Reply
GaryPrintnw
Newbie
Posts: 7
Joined: Fri Feb 21, 2014 6:34 pm

Organizing Files

Post by GaryPrintnw »

Hi, I am currently writing a script to organize my files for me, and I am coming across a simple logical issue. What I am doing is having my MIS system output a x XML File. I have switch read it in my script for the Job Number in the XML.



I have the script go find the folder to move in a place where all files are kept for waiting to work on area and move it to the new place where my prepress department will work on it.



I can get the folder to move and i can get it to create the organization of all the folders that are needed. I just can not get the files that are in the files to move in to a sub folder of the folders that I'm creating.



There's three ways that i have tried to do this, but neither work quite right.



First way was to create the folder using the scripting in the new place where i want my prepress department to work on them, Great! the issue i have here is that I create the folders, there but can not figure out how to take the files that i found in the waiting to work on area and push them into a new folder which i created in the prepress working files area. I can push them to the top layer though.



Second way was to find the folder that needs to be moved change the name of it to what i want, add the folder organization that i want in to that folder, which is great but the file are still on the top layer and i want them to be organized into different folders that have been created in the moving folder and then move the folder to the working area.





Does anybody have an idea on the best way to do this, basically moving a folder of files to a place that does not exist until the program has ran and creating and renaming things along the way.
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

Organizing Files

Post by freddyp »

I can only guess at how you are trying to accomplish what you need, but here are probably different approaches you could try.



1: Assumption: all the files are being moved into some folder structure with the same root folder. Your script finds the files in a certain location and on that basis it knows where the file has to go in that output folder structure. Store this path in the hierarchy of the job (job.setHierarchyPath). The parameter of this is an array of strings that represent the folder names of the path, so ["abc","def",ghi] for the path abc/def/ghi/file.ext. At the end of the script you send the job to single and if the flow ends in an "Archive hierarchy" (which is set to the common root folder) the whole path will be created automatically and the file delivered in the right folder. Do not forget to set the subfolder level to a high number to avoid the path from being truncated.



2: You seem to have successfully created the folder path, but you cannot get the file in there. Create the correct command line for moving the file to where you want it as a string and then:

var status = Process.execute(command);



Freddy
Post Reply