Skip to main content
Question

Extract zip files and retain specific files

  • September 4, 2020
  • 4 replies
  • 803 views

sunsilk11
Contributor
Forum|alt.badge.img+6

Hi I have a number of zip files. I would like to extract these and copy only specific ones to a folder. The list of required files is in a text file.

Any idea of the best way to achieve this

4 replies

danilo_fme
Evangelist
Forum|alt.badge.img+44
  • Evangelist
  • September 4, 2020

Hi @sunsilk11​ 

 

The custom transformer ZipExtractor can be used for extract zip files. You can use the transformer FeatureMerger to get the same names from files ( zipfiles * tex files ).

By last the Writer FileCopy to copy.

 

Thanks in Advance,

Danilo


david_r
Celebrity
  • September 4, 2020

The TempPathnameCreator is very helpful if you prefer to unzip the entire contents before copying only the desired files to the target directory. Folders created by the TempPathnameCreator are automatically deleted when FME terminates.


sunsilk11
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • September 4, 2020
david_r wrote:

The TempPathnameCreator is very helpful if you prefer to unzip the entire contents before copying only the desired files to the target directory. Folders created by the TempPathnameCreator are automatically deleted when FME terminates.

Thanks. I need to extract files from a dozen zip files. Would I need 12 zipExtractor for this or is there a more efficient way?


david_r
Celebrity
  • September 4, 2020
sunsilk11 wrote:

Thanks. I need to extract files from a dozen zip files. Would I need 12 zipExtractor for this or is there a more efficient way?

Unless the zip files are enormous, I would do as follows:

  1. Create a temp directory with the TempPathnameCreator
  2. Unzip everything to the temp dir (ZipExtractor from the FME Hub)
  3. On the "Files" output port, connect a FilenamePartExtractor
  4. Use the result in a FeatureMerger to with list of files to keep (see answer from @danilo_fme​ )
  5. For each file to keep, use the File Copy write to copy the file to the target directory

Reply


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