Skip to main content
Solved

Delete all pdf files in a folder?


vxn43
Supporter
Forum|alt.badge.img+17

In my workspace, I have an FTPCaller Transformer that uploads (copies) files from a folder to an ftp site.

 

Next step is I want to delete all the pdf files in the source folder from where all the pdf files were copied to the ftp site. I have tried attaching this solution (File Copy - DELETE (safe.com)) after the FTPCaller but the files are not deleted, besides it seems to only delete a single named file. Does not seem to handle wildcards like *.pdf.

 

I also tried FileDeleter FME Hub (safe.com) and it not only did not delete the files, but I was reading it does not work in FME Flow, and I plan to upload my workspace to FME Flow and run it on an incremental schedule.

 

Should I create a separate workspace that just deletes all the pdf files in the folder and run it after the files are copied to the ftp site?

 

In essence, what is the best way to delete *.pdf files in a folder?

 

 

Best answer by danminneyatsaf

timh wrote:

Thanks for the help. I did manage to get FileDeleter to work in FME Form and it works in FME Flow as well. I have the answer I need, but more curious as why I could not get the SystemCaller to work...

 

I tried SystemCaller using this parameter:

SystemCaller_del_parameter_failed_to_execute 

But it did not delete the files and the log message is:

SystemCaller: Failed to Execute `del \\\\myservermachine\\Z_shared\\FME Workflow\\Reports to FTP\\*.pdf'

 

Any suggestions on how I can modify the SystemCaller parameter to delete the files?

Hey Tim,

My best guess would be the UNC path (network drive) isn't being accepted by the SystemCaller. If you try the same command in Command Prompt, does it work?

Does the del command work when you try deleting a file on your local hard drive?

I was able to get the del command to work when specifying a wildcard in a network drive, so it is possible.

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

4 replies

geomancer
Evangelist
Forum|alt.badge.img+47
  • Evangelist
  • October 27, 2023

If you only need the PDF files inside the workspace, there is no need to write them to disk.

Instead you can use a TempPathnameCreator to provide a path to temporarily store the PDF files. FME will automatically delete the PDF files at the end of the workspace.

 

 


nielsgerrits
VIP
geomancer wrote:

If you only need the PDF files inside the workspace, there is no need to write them to disk.

Instead you can use a TempPathnameCreator to provide a path to temporarily store the PDF files. FME will automatically delete the PDF files at the end of the workspace.

 

 

This. But if you really need to delete files you can always use a SystemCaller and use something like

del c:\temp\*.pdf

or use the PythonCaller if you are more familiar with Python.

 

I must admit that using the SystemCaller to delete files with a workbench on server scares me a bit, especially using wildcards. I had some nasty experiences with unexpected input for the systemcaller resulting in more deleted files than I had anticipated. But it can be done.


vxn43
Supporter
Forum|alt.badge.img+17
  • Author
  • Supporter
  • October 27, 2023

Thanks for the help. I did manage to get FileDeleter to work in FME Form and it works in FME Flow as well. I have the answer I need, but more curious as why I could not get the SystemCaller to work...

 

I tried SystemCaller using this parameter:

SystemCaller_del_parameter_failed_to_execute 

But it did not delete the files and the log message is:

SystemCaller: Failed to Execute `del \\\\myservermachine\\Z_shared\\FME Workflow\\Reports to FTP\\*.pdf'

 

Any suggestions on how I can modify the SystemCaller parameter to delete the files?


danminneyatsaf
Safer
Forum|alt.badge.img+12
timh wrote:

Thanks for the help. I did manage to get FileDeleter to work in FME Form and it works in FME Flow as well. I have the answer I need, but more curious as why I could not get the SystemCaller to work...

 

I tried SystemCaller using this parameter:

SystemCaller_del_parameter_failed_to_execute 

But it did not delete the files and the log message is:

SystemCaller: Failed to Execute `del \\\\myservermachine\\Z_shared\\FME Workflow\\Reports to FTP\\*.pdf'

 

Any suggestions on how I can modify the SystemCaller parameter to delete the files?

Hey Tim,

My best guess would be the UNC path (network drive) isn't being accepted by the SystemCaller. If you try the same command in Command Prompt, does it work?

Does the del command work when you try deleting a file on your local hard drive?

I was able to get the del command to work when specifying a wildcard in a network drive, so it is possible.


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