How to Mass Convert 7Z to ZIP
For Windows
Recommended solution due to its ease of use and speed: Torrentzip.NET
Other solutions:
Script
Thanks to Abelenki for the script.
Instructions:
- Replace D:\emulation\ExtraStuff\7-Zip\7z.exe with 7-Zip location in your system.
- Put Mass Convert 7Z To ZIP.cmd to your folder with 7Z files.
- Run Mass Convert 7Z To ZIP.cmd from this folder (it will convert all you 7Z/T7Z files to standard ZIP files).
The script, which should be saved as "Mass Convert 7Z To ZIP.cmd":
set sevenzip=D:\emulation\ExtraStuff\7-Zip\7z.exe for %%F in (*.7z) do ( REM Extract... %sevenzip% x "%%F" -o"%%F contents" REM Change directory, create zip of contents of directory... CD "%%F contents" %sevenzip% a -tzip "../%%~nF.zip" * CD .. REM Delete the old files DEL "%%F" /F /Q RMDIR "%%F contents" /S /Q )
For Linux and Mac OS X
Thanks to Obiwantje and filou for the script.
Instructions:
- In Linux it needs both coreutils and parallel as well:
sudo apt-get install moreutils
sudo apt-get install parallel
- In Mac OS X, it needs coreutils and parallel to be installed.
brew install coreutils parallel
- By default it uses N+1 cores with N the numbers of cores of the computer. As it can be memory hungry, it is possible to fix the number of attributed cores with the MAX_CPU variable.
Script
The script follows:
#! /bin/bash # 7z_to_tzip.sh source_dir target_dir IN_DIR=$(readlink -f "$1" 2>/dev/null || realpath "$1") OUT_DIR=$(readlink -f "$2" 2>/dev/null || realpath "$2") MAX_CPU=$(( $(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu) + 1 )) #MAX_CPU=4 archive_convert(){ IN_DIR=$1 OUT_DIR=$2 SOURCE_FILE=$3 TMP_DIR=$(mktemp -dt tmp.XXXXXXXXXX) cd "$TMP_DIR" || exit 1 TARGET_DIR=$(dirname "${SOURCE_FILE/$IN_DIR/$OUT_DIR}") TARGET_FILE="${TARGET_DIR}/$(basename "${SOURCE_FILE}" .7z).zip" if [ ! -d "${TARGET_DIR}" ]; then mkdir -p "${TARGET_DIR}" fi if [ ! -f "${TARGET_FILE}" ]; then 7z x -y "${SOURCE_FILE}" zip -1 -r "${TARGET_FILE}" . fi cd "$TMPDIR" || exit 1 rm -rf "$TMP_DIR" trrntzip "${TARGET_FILE}" return $? } if [ ! -d "${OUT_DIR}" ]; then mkdir -p "${OUT_DIR}" fi export -f archive_convert LOCAL_TMP="$(pwd)/tmp" if [ ! -d "${LOCAL_TMP}" ]; then mkdir -p "${LOCAL_TMP}" fi find "${IN_DIR}" -type f -name '*\.7z' -print0 | parallel -q0 --tmpdir "${LOCAL_TMP}" -j${MAX_CPU} archive_convert "${IN_DIR}" "${OUT_DIR}" {} #rm -r "${LOCAL_TMP}"