linux下QQ截图文件默认放在:/home/user_name/.config/tencent-qq/AppData/file/ 目录下,貌似还不支持自定义。这个目录用文件夹打开很不方便,于是想写个脚本进行实时自动转移。简单实现一下,基本满足需求。代码如下:
#!/bin/bash
function is_running() {
num=`ps -ef |grep "sync_snapshot\.sh" |wc -l`
if [ $num -gt 2 ]; then
return 1
else
return 0
fi
}
function sync_snapshot() {
snapshot_src_dir=/home/zhoumin/.config/tencent-qq/AppData/file/
snapshot_dst_dir=/home/zhoumin/snapshot/
index=0
suffix=.jpg
for entry in `ls $snapshot_src_dir |grep "\.jpg"$`; do
current=`date "+%Y-%m-%d %H:%M:%S"`
timestamp=`date -d "$current" +%s`
file_name=$timestamp-$index$suffix
mv $snapshot_src_dir/$entry $snapshot_dst_dir/$file_name
index=$[$index+1]
done
}
function main() {
is_running
if [ $? -eq 1 ]; then
echo "sync is running ... "
exit
else
echo "start sync ... "
fi
while [ 1 -eq 1 ]
do
sync_snapshot
sleep 1
done
}
main