Downloader - Create Daily & Monthly folders

I’m currently testing an automation to download the latest video from my Ring doorbell.
Had it running a while, so far so good !

However, I’m looking to do a little more housekeeping as the files get quite messy, especially when I’m trying to archive etc.

I’m trying to make it so that it’ll be organised into folders and if the folder doesn’t exist, then create it.

So the folder structure would be

  • 2021 (Year)
    April (Month)
    24 (Date)

Below is the current automation I have…

I know I might need to call a script to create the folders if they don’t exist, just not sure what to do exactly :slight_smile:

- id: 'xx'
  alias: 'xx'
  description: ''
  - platform: state
    entity_id: camera.front_door
    attribute: last_video_id
  condition: []
  - service: downloader.download_file
      url: '{{ state_attr(''camera.front_door'', ''video_url'') }}'
      subdir: '{{state_attr(''camera.front_door'', ''friendly_name'')}}'
      filename: '{{ state_attr(''camera.front_door'', ''friendly_name'') }} - {{ now().strftime("%d-%m-%Y-
        %H.%M.%S") }} - TEST.mp4'
  mode: single