#!/bin/bash

function cptimestamp() 
{
    if [[ -z $2 ]]; then
        echo "usage: cptimestamp <sourcefile> <destfile>"
        exit
    fi
    touch -d @$(stat -c "%Y" "$1") "$2"
}

function repakArchiv()
{
    echo "$1 -> ${1:0:-4}.7z"
    mkdir tmp
    cd tmp
    unzip -I CP866 ../$1
    7z a ../test/${1:0:-4}.7z * -mx9
    cd ..
    cptimestamp $1 test/${1:0:-4}.7z
    rm -Rf tmp
    # read -n 1
}

for z in *.zip; do
    repakArchiv $z
done

