I'm trying to create a python script that will log into an FTP server, change to a specific directory and download all files from that dir.
The FTP server has directories created daily and the dir name matches the date. for example:
drwxr-xr-x 2 user tenant 0 Nov 01 00:00 2017-11-01
drwxr-xr-x 2 user tenant 0 Nov 02 00:00 2017-11-02
drwxr-xr-x 2 user tenant 0 Nov 03 00:00 2017-11-03
drwxr-xr-x 2 user tenant 0 Nov 04 00:00 2017-11-04
drwxr-xr-x 2 user tenant 0 Nov 06 00:00 2017-11-06
drwxr-xr-x 2 user tenant 0 Nov 07 00:00 2017-11-07
I am able to get logged into the server but now how can I change into the directory that matches yesterday's date? For example, if today is 2017-11-07 I would need to change into 2017-11-06. I am using python 2.6.6.
I'm using this which I found from another post:
from datetime import date, timedelta
yesterday = date.today() - timedelta(1)
This works but how do I use 'yesterday' in my directory path?
Any help is much appreciated.