#!/bin/bash SOURCE="/tmp/test quellordner/" DESTPATH="/tmp/ziel" FolderCount=1 FolderFileLimit=5 FileCount=0 mkdir -p $DESTPATH/$FolderCount for f in $(ls "$SOURCE"); do FileCount=$(( $FileCount + 1 )) echo "f: $f" if [ $FileCount == $FolderFileLimit ]; then FileCount=0 FolderCount=$(( $FolderCount + 1 )) mkdir -p "$DESTPATH/$FolderCount" fi if [ $FileCount -le $FolderFileLimit ]; then cp "$SOURCE$f" "$DESTPATH/$FolderCount/" fi done