Copy and rename File using Hassio

Thanks. This worked for me. Using the SSH addon to test helped.
(Home Assistant Community Add-on: SSH & Web Terminal) . I had to fiddle with directory paths for it to work…

Edit: More details added.

In config file:

shell_command:
  copy_latest: 'cp $(ls -t1 /share/motioneye/outside_digoo_cam/timelapse_vids/*.mpg|head -n1) /config/www/motioneye_files/latest_timelapse.mpg'

Then you’ll see shell_command.copy_latest (etc.) appear in the services tool which you can use for testing.

This can be triggered by an automation or script service call:

#Timelapse:
- id: '5455454245'
  alias: Auto get timelapse
  initial_state: 'on'
  trigger:
    platform: time_pattern
    # Matches every hour at 10 minutes past whole
    minutes: 10
  action:
    - service: shell_command.copy_latest