【拿来即用系列】linux 文件夹拆分 十万个文件 拆分成十个文件夹 每个文件夹一万个。shell 脚本


path=$1

path1=$2

moved=0

target=

for i in `ls $path`

do

echo  $moved

if [ $moved -lt 10 ]; then

target=$path1/1

mv -v $path$i $target

fi

if [ $moved -ge 10 -a $moved -le 20 ]; then

target=$path1/2

mv -v $i $target

fi

if [ $moved -ge 20 -a $moved -le 30 ]; then

target=$path1/3

mv -v $i $target

fi

if [ $moved -ge 30 -a $moved -le 40 ]; then

target=$path1/4

mv -v $i $target

fi

if [ $moved -ge 40 -a $moved -le 50 ]; then

target=$path1/5

mv -v $i $target

fi

if [ $moved -ge 50 -a $moved -le 60 ]; then

target=$path1/6

mv -v $i $target

fi

if [ $moved -ge 60 -a $moved -le 70 ]; then

target=$path1/7

mv -v $i $target

fi

if [ $moved -ge 70 -a $moved -le 80 ]; then

target=$path1/8

mv -v $i $target

fi

if [ $moved -ge 80 -a $moved -le 90 ]; then

target=$path1/9

mv -v $i $target

fi

if [ $moved -ge 90 -a $moved -le 100 ]; then

target=$path1/10

mv -v $i $target

fi

echo $i 

echo $target

#mv -v $i $target

((moved++))

done

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一、Python简介和环境搭建以及pip的安装 4课时实验课主要内容 【Python简介】: Python 是一个...
    _小老虎_阅读 5,818评论 0 10
  • Linux习惯问题: 在vim编辑时,按了ctrl + s后,再按ctrl + q就可以继续执行了。ctrl + ...
    光着脚的鞋阅读 4,542评论 0 16
  • 1,使用source来执行脚本,相当于在一个shell下面执行脚本。互相可以可以调用。 bash执行脚本,开启...
    张鑫泽_2109阅读 425评论 0 0
  • [PHP]注释版php.ini ;;;;;;;;;;;;;;;;;;;; About php.ini ;;;;...
    雨后桥前阅读 311评论 0 0
  • 第一章 1.Linux是一套免费使用和自由传播的类UNIX操作系统,它可以基于Intel x86系列处理器以及Cy...
    yansicing阅读 5,484评论 0 9