Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Set your Telegram bot token and chat ID
- BOT_TOKEN="your_bot_token_here"
- CHAT_ID="your_chat_id_here"
- # Set the folder path where your files are located
- FOLDER_PATH="/path/to/folder"
- # Loop through all files in folder
- for file in $FOLDER_PATH/*
- do
- # Check if file is an image
- if [[ "$file" == "*.jpg" ]] || [[ "$file" == "*.jpeg" ]] || [[ "$file" == "*.png" ]] || [[ "$file" == "*.JPG" ]] || [[ "$file" == "*.JPEG" ]] || [[ "$file" == "*.PNG" ]]
- then
- # Upload image to Telegram
- curl -s -F chat_id="$CHAT_ID" -F photo=@"$file" https://api.telegram.org/bot$BOT_TOKEN/sendPhoto > /dev/null
- # Check if file is a video
- elif [[ "$file" == "*.mp4" ]] || [[ "$file" == "*.mov" ]] || [[ "$file" == "*.avi" ]] || [[ "$file" == "*.MP4" ]] || [[ "$file" == "*.MOV" ]] || [[ "$file" == "*.AVI" ]]
- then
- # Upload video to Telegram
- curl -s -F chat_id="$CHAT_ID" -F video=@"$file" https://api.telegram.org/bot$BOT_TOKEN/sendVideo > /dev/null
- else
- # Upload file to Telegram
- curl -s -F chat_id="$CHAT_ID" -F document=@"$file" https://api.telegram.org/bot$BOT_TOKEN/sendDocument > /dev/null
- fi
- # Delete file from folder
- rm "$file"
- done
- echo "All files uploaded to Telegram!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement