将x个文件移动到新文件夹

时间:2022-07-12 10:34:12

I have a folder with 10,000 images, I want to move them all so I have 100 images in each new sub folder. the new folders can be simply named 01,02,03 and so on. how can this be done from the command line in ubuntu? thanks

我有一个包含10,000张图像的文件夹,我想将它们全部移动,所以每个新的子文件夹中有100张图像。新文件夹可以简单地命名为01,02,03,依此类推。如何从ubuntu的命令行完成?谢谢

1 个解决方案

#1


#!/bin/bash

c=1; d=1; mkdir -p folder_${d}

for file in *
do
   if [ $c -eq 100 ]
   then
       d=$(( d + 1 )); c=0; mkdir -p folder_${d}
   fi
   mv "$file" folder_${d}/
   c=$(( c + 1 ))
done

#1


#!/bin/bash

c=1; d=1; mkdir -p folder_${d}

for file in *
do
   if [ $c -eq 100 ]
   then
       d=$(( d + 1 )); c=0; mkdir -p folder_${d}
   fi
   mv "$file" folder_${d}/
   c=$(( c + 1 ))
done