Unzip Files Without Overwriting
Step 1 — Ask for the target directory
Before running anything, ask the user:
"Which directory should I extract archives from?"
Accept absolute or relative paths. Expand ~ to the full home directory path if provided.
Step 2 — Detect the OS and run the correct script
macOS / Linux — run the bash script directly:
bash /path/to/skill-test/unzip-files.sh "/the/target/directory"
Windows — run the CMD wrapper (do NOT use pwsh or powershell directly):
C:\path\to\skill-test\run.cmd "C:\the\target\directory"
IMPORTANT: On Windows always use
run.cmd. Never invokepwshorpowershelldirectly.run.cmdcallspowershell.exe(Windows PowerShell 5.1) automatically.
Step 3 — Report results
Summarize what was extracted, renamed, and removed.
How the scripts work
- Accept a target directory as argument (defaults to
./ current directory if omitted) - Validate the directory exists and resolve it to an absolute path
- Search recursively through the directory and all subdirectories
.zip/.tar.gz/.tgz: extracted into a new subfolder named after the archive.gz(single file): decompressed in-place (name.gz→name)- If the output target already exists, the archive is renamed with
_1,_2, etc. — nothing is overwritten - Original archive files are deleted after successful extraction
Platform notes
| Feature | macOS/Linux (unzip-files.sh) |
Windows (run.cmd → unzip-files.ps1) |
|---|---|---|
.zip |
unzip |
System.IO.Compression.ZipFile |
.tar.gz / .tgz |
tar -xzf |
tar -xzf (Windows Server 2019+) |
.gz single file |
gunzip -c |
System.IO.Compression.GZipStream |