I was faced with another problem. I had to wait until the end of the recording period to be able to use the script.
Here is a new version, which makes it possible to run the script at any moment.
#!/bin/bash
to_dir=$1
cd $to_dir
maxFilesInDir=980
subdir=0
function check {
nFiles=`dir -1 | wc -l`
if [[ $nFiles -lt $maxFilesInDir ]]; then
  exit
fi
}
function createDir {
while [ -d $subDir ]; do
subdir=$((subdir+1))
subDir="$to_dir/$subdir/"
done
mkdir -p "$to_dir/$subdir"
idx=0
}
idx=$maxFilesInDir;
for i in *.jpg; do
if [ "$idx" == $maxFilesInDir ] ; then
check
createDir
fi
cmd="mv $i $to_dir/$subdir/$i"
$cmd
idx=$(($idx+1))
done
Geen opmerkingen:
Een reactie posten