Adding %Y%M%D to today string?

Hey hey…so, I’m trying Python and attempting to modify @john-geehreng 's Dated Time and Folder Script to change the format of the date to use within my ecosystem.


cript Name: add_dated_and_timed_folders

Script Version: 1.0

Flame Version: 2021.2

Written by: John Geehreng

Creation Date: 12.14.20

Update Date: 12.14.20

Description: This will create system folders in the media hub. The format will be 2020-12-14/1400.


I was attempting to modify the:

today = str(date.today())

…by adding an argument, like this…

today = str(date.today(%Y%M%D))

…to create a 20210128 format but Im getting an error in the shell about the the string not being able to take arguments.

If that string can’t take arguments, should I use a different technique?

Thanks!
r

This might not be the “right” way to do it, but I think it will work for you if you just want to remove the "-"s.

date = str(date.today())
today = date.replace("-","")

Here’s a good article:

look at the strftime command.

import datetime

x = datetime.datetime(2018, 9, 15)

print(x.strftime("%b %d %Y %H:%M:%S"))
1 Like