Skip to main content
Question

Script to Move Pdfs to folder location based on the name of the file

  • February 21, 2025
  • 2 replies
  • 38 views

winklerj
Participant
Forum|alt.badge.img

Hello,

Newbie to FME here, trying to create a simple script to move multiple pdf files all located in one folder to multiple folders which match the name of the folder. Tried using File Copy Writer but had no luck.

2 replies

bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • February 22, 2025

Do you mean “Move the PDF to a folder with the same name as the PDF File”?

Simplest approach perhaps:

  1. Use PATH Reader to the Source Folder.  Set Path Filter = *.PDF
  2. Use FilenamePathExtractor to get the File “root name” Eg.  “MyPDF” is the root name of “C:\Temp\MyPDF.pdf”.
  3. Use AttributeCreator to set a format attribute value filecopy_source_dataset to the value of path_unix to tell the Writer to source path of the file(s) (See File Copy Writer Help for what the different format attribute values do within the File Copy Writer)
  4. Write the files using File Copy Writer to set the destination SubFolder to Eg. “_rootname” and setting the File Operation to “Move”

Note: Don’t need FilenamePathExtractor if set the separate PATH Reader Parameter “Retrieve File Properties” to Yes, but sometimes that exposes more information than want on the Workspace and is a little slower to read.

Example workspace

 


davidlee
Supporter
Forum|alt.badge.img+7
  • Supporter
  • February 24, 2025

You can use transformer “RenameFile” on FMEhub that I created it. Hopefully it help you


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