Reputation: 11
I'm trying to automate an ftp upload with files that are in folders based on the day of the week. Since today is Tuesday I would like to have the script go to the //server/folder/Tuesday folder, and upload the files in that folder.
I have this:
os.chdir("//MTR-SRV/Creative/CHARGER/Monitor/Out")
cwd = os.getcwd()
print "1", cwd
but that just gets me to the folder right before the day folder. I need it to get to //MTR-SRV/Creative/Charger/Monitor/Out/Tuesday (or whatever today's date is)
any ideas?
Upvotes: 1
Views: 289
Reputation: 67063
You can get the day of the week like this:
>>> import time
>>> time.strftime('%A')
'Tuesday'
In your case, this ought to do the trick:
import time
dayofweek = time.strftime('%A')
os.chdir("//MTR-SRV/Creative/CHARGER/Monitor/Out/" + dayofweek)
Upvotes: 7
Reputation: 3236
import datetime
dayname = datetime.datetime.now().strftime('%A')
os.chdir("//MTR-SRV/Creative/CHARGER/Monitor/Out/%s" % dayname)
cwd = os.getcwd()
print "1", cwd
Upvotes: 1