I'm trying to upload videos to YouTube via a Bash shell script. I want to run this script for a specific folder where, when the script is run it, should select only the latest file inside this folder.
I have written the code to upload from shell, but need help to select the latest file automatically.
#!/bin/sh
# youtube-upload
read -p 'Title (default filename): ' TITLE # defaults to filename
read -p 'Privacy (public | unlisted | private): ' PRIVACY # defaults to private
read -p 'Video link:' LINK
PRIVACY="--privacy ${PRIVACY:-private}"
CREDENTIALS='--client-secrets=/home/thanos/Desktop/client_secrets.json'
VIDEO_ID="$(youtube-upload --title="$TITLE" $PRIVACY $CREDENTIALS $LINK)"
VIDEO_LINK="https://www.youtube.com/watch?v=$VIDEO_ID"
echo "$VIDEO_LINK" > ~/Desktop/Upload-Links/"$(date +%d%m%Y-%H%M%S).txt"
read -p "Upload Complete. Press any key to continue."`