Update x2t.sh
This commit is contained in:
parent
b10911e9b6
commit
45d1cd0da3
|
@ -8,10 +8,10 @@ ARIA2_RPC=/etc/transmission-daemon/aria2-rpc.sh
|
||||||
export LC_ALL=en_US.UTF-8
|
export LC_ALL=en_US.UTF-8
|
||||||
|
|
||||||
check_sub(){
|
check_sub(){
|
||||||
echo "check sub."
|
echo "check sub."
|
||||||
SAVEIFS=$IFS # setup this case the space char in file name.
|
SAVEIFS=$IFS # setup this case the space char in file name.
|
||||||
IFS=$(echo -en "\n\b")
|
IFS=$(echo -en "\n\b")
|
||||||
for subdir in $(find -maxdepth 1 -type d |grep ./ |cut -c 3-);
|
for subdir in $(find -maxdepth 1 -type d |grep ./ |cut -c 3-);
|
||||||
do
|
do
|
||||||
echo $subdir
|
echo $subdir
|
||||||
cd "$subdir"
|
cd "$subdir"
|
||||||
|
@ -26,9 +26,9 @@ convert_to_jpg(){
|
||||||
for ext in jpg JPG bmp BMP png PNG; do
|
for ext in jpg JPG bmp BMP png PNG; do
|
||||||
echo "ext is $ext"
|
echo "ext is $ext"
|
||||||
if [ ! $(find . -maxdepth 1 -name \*.$ext | wc -l) = 0 ];
|
if [ ! $(find . -maxdepth 1 -name \*.$ext | wc -l) = 0 ];
|
||||||
then
|
then
|
||||||
x2jpg $ext
|
x2jpg $ext
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
check_sub # check if has sub directory.
|
check_sub # check if has sub directory.
|
||||||
|
@ -36,11 +36,11 @@ convert_to_jpg(){
|
||||||
|
|
||||||
x2jpg(){
|
x2jpg(){
|
||||||
if [ ! -d origin ];then
|
if [ ! -d origin ];then
|
||||||
mkdir origin
|
mkdir origin
|
||||||
fi
|
fi
|
||||||
if [ ! -d /tmp/jpg ]; then
|
if [ ! -d /tmp/jpg ]; then
|
||||||
mkdir /tmp/jpg
|
mkdir /tmp/jpg
|
||||||
chmod -R 777 /tmp/jpg
|
chmod -R 777 /tmp/jpg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmp_fifofile="/tmp/$$.fifo"
|
tmp_fifofile="/tmp/$$.fifo"
|
||||||
|
@ -68,6 +68,7 @@ x2jpg(){
|
||||||
exec 6>&- # close fd6
|
exec 6>&- # close fd6
|
||||||
|
|
||||||
mv /tmp/jpg/* .
|
mv /tmp/jpg/* .
|
||||||
|
pwd
|
||||||
rm -r origin
|
rm -r origin
|
||||||
|
|
||||||
echo 'DONE!'
|
echo 'DONE!'
|
||||||
|
@ -78,7 +79,8 @@ x2jpg(){
|
||||||
while [ -f /tmp/.x2t ]
|
while [ -f /tmp/.x2t ]
|
||||||
do
|
do
|
||||||
echo "wait other job exit"
|
echo "wait other job exit"
|
||||||
sleep 2
|
#sleep 2
|
||||||
|
sleep $[ ( $RANDOM % 10 ) + 1 ]
|
||||||
done
|
done
|
||||||
|
|
||||||
touch /tmp/.x2t
|
touch /tmp/.x2t
|
||||||
|
@ -103,7 +105,7 @@ if [ $(ls $tmpdir | wc -l) = 1 ]; then # check if has folders, and mv the unzipe
|
||||||
rmdir $tmpdir
|
rmdir $tmpdir
|
||||||
else
|
else
|
||||||
mv $tmpdir "$DIR"
|
mv $tmpdir "$DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $DIR
|
echo $DIR
|
||||||
if [ -d "$DIR" ]; then
|
if [ -d "$DIR" ]; then
|
||||||
|
@ -119,4 +121,5 @@ else
|
||||||
echo "$DIR not exist."
|
echo "$DIR not exist."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sync
|
||||||
rm /tmp/.x2t
|
rm /tmp/.x2t
|
||||||
|
|
Loading…
Reference in New Issue