#!/bin/bash
#This script should be present in the parent directory of the directory which is supposed to
#be partitioned.
#The files in the input directory will be moved to each of these partitions
#eidt by www.jquerycn.cn
if [ $# -ne 1 ]; then
echo "usage: $0 directory_name" 1>&2
exit 1
fi
dir="$1_partitioned"
mkdir $dir
subdir=1
mkdir "$dir/$subdir"
incr=0
for fname in $1/*
do
if [ $incr -gt 1000 ]; then
subdir=$((subdir+1))
mkdir "$dir/$subdir"
incr=0
fi
mv $fname "$dir/$subdir"
incr=$((incr+1))
done