Skip to content

Instantly share code, notes, and snippets.

@limitedeternity
Last active May 1, 2021 18:05
Show Gist options
  • Save limitedeternity/fa54878894ac4be05ea48f52c57532d3 to your computer and use it in GitHub Desktop.
Save limitedeternity/fa54878894ac4be05ea48f52c57532d3 to your computer and use it in GitHub Desktop.
Fix zip archives created on Windows to work on Linux
# "archive.zip" should extract to "archive" folder
7z x archive.zip
# But shit happens. And now we are going to fix it:
: "
Before:
-- archive\log.txt
-- archive\renpy\ast.py
After:
-- archive
|_____-- log.txt
|_____-- renpy
|__________-- ast.py
"
for file in *\\*; do target="${file//\\//}"; mkdir -p "${target%/*}"; mv -v "$file" "$target"; done
# In case you need to make every file in "archive" folder executable:
find archive/ -type f | xargs -n 1 chmod +x -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment