Time: 2024-04-12 04:29:32
Author: Jackasher
HexoShell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| #!/bin/bash
hexo_dir="/root/blog"
markdown_dir="/root/Markdown"
category=Jack tag=Blog
read -p "输入你想要的存放的目录:" category read -p "输入你想要打上的标签:" tag
current_date=$(date "+%Y-%m-%d %H:%M:%S") current_time=$(date "%H:%M:%S")
if [ -z "$category" ]; then category="Jack" fi
if [ -z "$tag" ]; then tag="Blog" fi
for file in "$markdown_dir"/*.md; do if [ -f "$file" ]; then filename=$(basename -- "$file" .md)
if [ -f "$hexo_dir/source/_posts/$filename.md" ]; then echo "Skipping $filename.md - File already exists in destination directory." rm "$file" echo "Deleted $filename.md from $markdown_dir/" else current_time=$(date "+%Y-%m-%d %H:%M:%S")
echo -e "\nTime: $current_time\nAuthor: Jackasher" | cat - "$file" > temp && mv temp "$file"
echo -e "---\ntitle: $filename\ncategories: $category\ntags: $tag\n---\n" | cat - "$file" > temp && mv temp "$file"
mv "$file" "$hexo_dir/source/_posts/" echo "Moved $filename.md to $hexo_dir/source/_posts/" fi fi done
cd "$hexo_dir"
hexo generate
|