From 52512af151e2c34488d9a240637f1f17b4b5df56 Mon Sep 17 00:00:00 2001 From: AlterWare - WSL Date: Wed, 21 May 2025 22:44:26 +0200 Subject: [PATCH] init --- LICENSE | 29 +++++++++++++++++++++++++++++ README.md | 24 ++++++++++++++++++++++++ list-iwd.sh | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100755 list-iwd.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..eade6ef --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2025, AlterWare +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5a06e69 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# IWD Archive Lister + +This script scans the `main/` and `iw4x/` folders under a specified root directory for `.iwd` files (which are ZIP archives). For each `.iwd` file found, it extracts the list of files inside the archive using `7z` and writes the output to a `.txt` file in a folder called `out/`. + +Each `.iwd` file gets its own `.txt` file in the `out/` directory, with the same base name (e.g., `iw_00.iwd` -> `out/iw_00.iwd.txt`). + +## Requirements + +- [`7z`](https://www.7-zip.org/) command-line tool + +### Install 7z on Debian/Ubuntu: + +```bash +sudo apt update +sudo apt install p7zip-full +``` + +### Usage + +```bash +./script.sh +``` + +Where `` is the path that contains both `main/` and `iw4x/` subfolders. diff --git a/list-iwd.sh b/list-iwd.sh new file mode 100755 index 0000000..2b19ebb --- /dev/null +++ b/list-iwd.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -e + +SEVENZIP_BIN="${SEVENZIP_BIN:-7z}" + +if [[ $# -ne 1 ]]; then + echo "Usage: $0 " + exit 1 +fi + +ROOT_DIR="$1" +MAIN_DIR="$ROOT_DIR/main" +IW4X_DIR="$ROOT_DIR/iw4x" + +OUT_DIR="out" + +if [[ ! -d "$MAIN_DIR" || ! -d "$IW4X_DIR" ]]; then + echo "Error: '$MAIN_DIR' or '$IW4X_DIR' directory not found." + exit 1 +fi + +mkdir -p "$OUT_DIR" + +process_iwd_files() { + local folder="$1" + find "$folder" -type f -iname '*.iwd' | while read -r iwd_file; do + # Output text file in same dir with same basename + base_name="$(basename "$iwd_file")" + output_file="$OUT_DIR/${base_name}.txt" + echo "Processing $iwd_file -> $output_file" + "$SEVENZIP_BIN" l -ba "$iwd_file" | grep -oP '(?<=^.{53}).*' > "$output_file" + done +} + +process_iwd_files "$MAIN_DIR" +process_iwd_files "$IW4X_DIR"