ubuntuusers.de

Unbenannt

Datum:
3. Dezember 2014 18:38
Code:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/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