一个文件夹里有30000(00000-30000)个文件,我想把他分到30个文件夹(代码生成)内,并且文件夹名为00000-01000,01001-02000 .....
1、新建00000-30000
#!/bin/bash
#touch
i=0
while [ $i -le 30000 ]
do
touch $(printf "d\n" $i)
((i ))
done
2、新建目录及复制文件
#!/bin/bash
i=1
aaa=$i 1
path=/tmp/test/111
path2=/tmp/test/1
#mkdir $path/''0''$i''000''''-''''0''$aaa''000''
#$i=$[$i 1]
#cp $path2/00* $path/''0''$i''000''''-''''0''$aaa''000''
for i in $(seq 30);
do
bbb=$[$i-1]
if [ $i -lt 10 ];then
mkdir $path/''0''$bbb''001''''-''''0''$i''000''
cp $path2/''0''$bbb* $path/''0''$bbb''001''''-''''0''$i''000''
else
bbb=$[$bbb 1]
i=$[$i-1]
mkdir $path/$i''001''''-''$bbb''000''
cp $path2/$i* $path/$i''001''''-''$bbb''000''
fi
done
存在的问题:09000-10000 会生成9000-10000, 才学这个地方没有好,希望大家批评指正,谢了!!!
本文出自 “timemaster” 博客,请务必保留此出处http://timemaster.blog.51cto.com/30055/701342
|