#!/bin/bash
# Various configuration information
# look here,remote_path base_url push_path The last side does not have parameters \
remote_path="temp" # Upload default path
base_url="https://cdn.jsdelivr.net/gh/zygds/cdn@master/img" # Custom domain name
push_path="D:\Github\cdn\img"
# Upload pictures
for i in "$@"; do
current=`date "+%Y-%m-%d %H:%M:%S"`
timeStamp=`date -d "$current" +%s`
currentTimeStamp=$((timeStamp*1000+`date "+%N"`/1000000))
# echo $currentTimeStamp
# print time
new_name=$currentTimeStamp.${i##*.}
# echo $new_name
# print file.path
push_paths=$push_path'\'$remote_path'\'$currentTimeStamp.${i##*.}
# echo $push_paths
# copy old file to new file
cp $i $push_paths
# copy file
done
# TODO Here, I have completed the task of copy, paste and rename. How to pass it to typeora? You can modify it at will
# Output results
echo "Upload Success:"
for file in "$@"; do
IFS='/' read -r -a array <<< "$file"
id="${#array[@]}"
echo "$base_url"'/'"$remote_path"'/'"$new_name"
done