Skip to main content
Solved

FileCopy Writer - possible to copy specified files instead of everything in directory?

  • February 19, 2020
  • 5 replies
  • 11 views

Forum|alt.badge.img

Hello everyone,

I am attempting to copy a select number of files from a given directory and came across the FileCopy writer. After experimenting with it, it appears that it is copying all the files specified in the source directory whereas I would like to specify which ones it copies instead. Can anyone confirm this limitation in the writer? And of course, I would be very happy to hear any ideas and workarounds for this. I am considering using PythonCaller to accomplish this but I would like to avoid this if at all possible.

Best answer by ebygomm

It's not a limitation of the writer so it sounds like you've not got it setup quite right. If you have the filecopy_source_dataset set to a folder rather than a file it will copy the whole folder

View original
Did this help you find an answer to your question?

5 replies

ebygomm
Influencer
Forum|alt.badge.img+38
  • Influencer
  • Best Answer
  • February 19, 2020

It's not a limitation of the writer so it sounds like you've not got it setup quite right. If you have the filecopy_source_dataset set to a folder rather than a file it will copy the whole folder


david_r
Celebrity
  • February 19, 2020

In addition to what @ebygomm said, you can also use the "Directory and File Pathnames" reader to get all the filenames in a specific location and then e.g. use the Tester or whatever to select only the files you want to process with the FileCopy writer.


Forum|alt.badge.img
  • Author
  • February 19, 2020
david_r wrote:

In addition to what @ebygomm said, you can also use the "Directory and File Pathnames" reader to get all the filenames in a specific location and then e.g. use the Tester or whatever to select only the files you want to process with the FileCopy writer.

This is a relief to hear though I can't seem to determine the error(s). I have attached a screenshot of the model. Note, the source directory has over 400 .tif files. I only want the ones I've passed through the testfilter to be written to the destination, but instead all of the .tif files in the source directory (400+) are getting written.


ebygomm
Influencer
Forum|alt.badge.img+38
  • Influencer
  • February 19, 2020
javsal wrote:

This is a relief to hear though I can't seem to determine the error(s). I have attached a screenshot of the model. Note, the source directory has over 400 .tif files. I only want the ones I've passed through the testfilter to be written to the destination, but instead all of the .tif files in the source directory (400+) are getting written.

It looks like the value you are using for filecopy_source_dataset is the entire folder, it needs to include the filename as well

An example

If you want to copy a file called image.tif that's in location C:\\TEMP\\2020 to a new folder called current in C:\\TEMP you need the attributes setting as follows

filecopy_source_dataset: C:\\TEMP\\2020\\image.tif

filecopy_dest_dataset: C:\\TEMP\\current

filecopy_dest_filename: image.tif


Forum|alt.badge.img
  • Author
  • February 19, 2020
ebygomm wrote:

It looks like the value you are using for filecopy_source_dataset is the entire folder, it needs to include the filename as well

An example

If you want to copy a file called image.tif that's in location C:\\TEMP\\2020 to a new folder called current in C:\\TEMP you need the attributes setting as follows

filecopy_source_dataset: C:\\TEMP\\2020\\image.tif

filecopy_dest_dataset: C:\\TEMP\\current

filecopy_dest_filename: image.tif

@ebygomm Thank you very much for sharing this. It's working now! The misunderstanding was that I was under the impression that the filecopy_source_dataset only refered to the directory path but as you illustrated it requires the file path.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings