summaryrefslogtreecommitdiff
path: root/bash/extractZip.sh
blob: b0f38d8a889e2f4e47910a38b44e17a6bd36e477 (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/zsh

tmpDir="Files/"

directory() {
    flag="d"
    cd "$1"

    for file in *.zip;  do
        dirName=$(getFilePath "$flag" "$file")
        if [ -d "$dirName" ]; then
            rm -r "$dirName"
        fi
        
        mkdir -p "$dirName"

        tar zxf "$file" -C "$dirName"
    done
}

run() {
    if [ $# -lt 1 ];    then
        echo "operator: bad use"
        exit 1

    elif [ $n -eq 1 ];  then
        if [ -d "$1" ];   then
            directory "$@"

#        elif [ -f $1 ]; then
#            files "$@"

        else
            echo "$0: wrong file"

        fi

#    else
#        files "$@"
    fi
}

run "$@"