Skip to content

Instantly share code, notes, and snippets.

@zhangyingda
Created November 12, 2022 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhangyingda/06d1c6b451402e9ab5298f6fae5f83fc to your computer and use it in GitHub Desktop.
Save zhangyingda/06d1c6b451402e9ab5298f6fae5f83fc to your computer and use it in GitHub Desktop.
Some bash code
#!/bin/bash
while true
do
echo -e "\033[2J\033[1;1H`tail /var/log/system.log`"
sleep 1
done;
#!/bin/bash
# 每日故宫图片下载
for month in {01,02,03,04,05,06,07,08,09,10,11,12};
do
mkdir -p 2015$month;
cd 2015$month;
for day in {1,2,3,4,5,6,7,8,9};
do
wget -t 3 http://mobileapps.dpm.org.cn/Res/2015$month/2015-$month-0$day\_content.jpg;
sleep 8;
done
if($month < 7 && $month%2=0) then
$max=30;
else
$max=31;
fi
if($month > 6 && $month%2=0) then
$max=31;
else
$max=30;
fi
if($month=2) then
$max=28;
fi
for day in {10..$max}
do
wget -t 3 -T 3 http://mobileapps.dpm.org.cn/Res/2015$month/2015-$month-$day\_content.jpg;
sleep 8;
done
cd ..
done
#!/bin/bash
#### 大写改小写,这个是用来更改从 Linux 当中提取出来的SSDT 文件名的 ###
DIR=`find -type d | grep -E './*[A-Z].*' | awk 'BEGIN{FS="/"}{print $2}'`
#这里是查找当前目录下的所有包含了大写字母的目录
for file in $DIR
do
mv $file `echo $file | tr 'A-Z' 'a-z'` #循环重命名目录,将大写全部转为小写
done
# 批量更改扩展名
find .|sed 's/\.\///g'|sed 's/\.dat//g'|while read i; do mv $i.dat $i.aml; done
# 主文件名小写改大写
find .|sed 's/\.\///g'|sed 's/\.aml//g'|while read i; do mv $i.aml `echo $i|tr 'a-z' 'A-Z'`.aml ; done
##################### 蔣勳 - 細說紅樓夢 - 第27回下.mp3 ###########################
find .|sed 's/蔣勳//g'|sed 's/ //g'|sed 's/-//g'|sed 's/第//g'|sed 's/回//g'
#来看超级语句
ls|awk '{print "mv \""$0"\" "$5""}'|bash
#得到的文件名就是
#第27回下.mp3
#接下来写一段脚本
#!/bin/bash
for file in `ls`
do
number=${file:1:2}
addon=${file:4:1}
name="细说红楼梦"$number$addon".mp3"
mv $file $name;
done
#得到文件名
#细说红楼梦64下.mp3
#用 python 批量更改 mp3tags
#!/usr/bin/env python
#coding:utf-8
import os
import re
import sys
import eyed3
if __name__ == "__main__":
if len(sys.argv)!=2:
print("please input mp3 directory")
exit()
dir=sys.argv[1]
for filename in os.listdir(dir):
filepath=os.path.join(dir,filename)
if(filename.endswith("mp3")):
print(filename)
try:
audiofile=eyed3.load(filepath)
audiofile.tag.title=u""
audiofile.tag.artist=u'蒋勋'
audiofile.tag.album=u'细说红楼梦'
audiofile.tag.album_artist=u'蒋勋'
audiofile.tag.comment=u'不惜歌者苦,但伤知音稀'
audiofile.tag.subtitle=u''
audiofile.tag.save()
except:
pass
#print("mp3tag edit for %s %s done",filepath,filename)
else:
print("Error",filepath)
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment