How to delete files with a Python script from a FTP server which are older than 7 days?

前端 未结 5 1643
遥遥无期
遥遥无期 2020-12-03 15:25

I would like to write a Python script which allows me to delete files from a FTP Server after they have reached a certain age. I prepared the scipt below but it throws the e

5条回答
  •  情深已故
    2020-12-03 16:13

    Well, it looks like the error you are seeing has to do with the fact that you are trying to remove the 'test123' directory from your local machine, not the FTP site. The FTP docs have a method called delete, and that's what you'd want to use to remove the file. As far as testing whether or not something is 7 days old or not, you might actually have to pull those files down from the FTP temporarily then check the modify times before using FTP.delete.

提交回复
热议问题