您的位置:首页 > 运维架构 > Linux

linux下保存firefox的缓存图片

2013-03-07 18:17 369 查看
这是一个学习linuxshell编程过程中制作的小工具,废话不说。开始:

这个工具一共有两个shellscript。第一个是webimage.bash这个script的作用就是在firefox的缓存目录下递归查找JPEG文件。第二个是test_image_size.bash这个文件的作用是对webimage.bash找到的图片进行筛选。小于60000B的文件不保存。

第一个文件:webimage.bash

#!/bin/bash

#copyright by lingbofeiyun

#This shell script is to search for firefox Cache and save film to~/Videos

#change to firefox Cache directory,this may different to you ownsystem

cd /home/yxy/.mozilla/firefox/700doz1r.default/Cache

#the loops function

loops() {

for film in *

do

if [ -d $film ]  #if film is directory change tothis directory and recursion run loops

then

cd $film

loops

cd ..       #change backto parent directory

elif [ -f $film ]

then

exitcode=0

#first test the file is image or not after that calltest_image_size.bash with ll parameter

message=$(file $film|grep "JPEG") &&exitcode=$(test_image_size.bash  $(ls -l$film))

if [ "$exitcode" = 1 ]

then

cp $film /home/yxy/Pictures/Webcam

fi

fi

done

}

loops    #shellstart running

exit 0

第二个文件:test_image_size.bash

#!/bin/bash

#copyright by lingbofeiyun

#This shell script is test image file's size. If image bigger than50KB return 1,else return 0

#test the fifth parameter is greater than 60000 or not.

if [ $5 -gt 60000 ]

then

echo 1

else

echo 0

fi

这样的话运行第一个文件就会调用第二个文件。浏览完图片后运行webimage.bash图片就会保存。稍加修改就会变成保存网上的flash电影,也就是网页上看的电影。下一篇我回给出代码。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell