Skip to main content

Hi,

I want to copy files based on workspace result values.

Example: a, b, c builders are applied for tenders of xyz road construction. All 3 companies tenders are integrated into one document and named as xyz road (its same as fme workspace result road names)

so when fme workspace result record contains xyz road, then pickup "xyz road" excel/pdf tender files and copy them into a specified folder path (or create new folder and copy files).

Any guidance on how to check the result road names with external files present in a directory (Lookup tables?)? is it possible in an easy way to automate it ? How can i compare result and copy respective files into a specified folder. Any guidance is helpful.

Thanks,

khk

The "Directory and File Pathnames"-Reader and the "PythonCaller"- or "SystemCaller"-Transformers could be helpfull. You can also use the Workspace Parameter "Shutdown Python Script" to do some afterwork.


Hi stalknecht,

Thanks for throwing some light. I didn't find "Directory and File Pathnames"- Reader, in which category it is present.?


Hi stalknecht,

Thanks for throwing some light. I didn't find "Directory and File Pathnames"- Reader, in which category it is present.?

It is not a transformer located in a category but a type of reader you can insert in your workspace.

I also would go with a PythonCaller, get the value of the attribute, create a URL for the files to copy and use the os.path.copy() method to copy the correct files.


I would go with the "File Copy"Writer. That writer will take arguments for source files and destination folder and filename. The attributes can be derived from attributes from a file (in your case the abc and xyz examples).


@khk

I personally think the file copy writer as erik_jan pointed out would be a lot simpler.

You could use an attribute creator with conditional value set to each 'xyzroad' to grab the external files for and then set that as the filecopy_source_dataset value. If you have multiple different values then you could concatenate the basename (assuming the roads share the same name as your external files) of the road dataset with the path name and .xls (or what ever your external files are) and then set that attribute as the filecopy_source_dataset.


Hi,
Done as below. I was thinking of creating variable for result features storage and 
reading pdf files to copy based on result names. But no need of variable creation with 
help of lookup table. Copy file is done with python caller.
import os
import fme
import fmeobjects
import shutil
def processFeature(feature):  
    # Create output directory with T_ID if the directory doesn't exist 
    dst = '//localhost/d$/Data/Output_Documents/PDF_Outputs/' + FME_MacroValues/'T_ID'] + '/PDF/'
    fname =  feature.getAttribute('Route_Lookup')
    if not os.path.exists(dst):
        os.makedirs(dst)
    src='//localhost/d$/Data/Route/' + fname
    shutil.copyfile(src, dst + fname)
    pass
class FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
        self.pyoutput(feature)
    def close(self):
        pass

Reply