unityextract: easier to read and also handles files better

This commit is contained in:
yosh 2024-04-05 18:12:13 -04:00
parent c0b92df7bb
commit a71970f1c6
1 changed files with 8 additions and 1 deletions

View File

@ -1,7 +1,14 @@
#!/bin/sh
set -euf
set -x
tmp="$(mktemp -d)"
tar -x -C "$tmp" -f "$1"
find "$tmp" -name 'asset' -exec sh -c 'SRC="$1"; DESTFILE="$(cat "${SRC%/*}/pathname")"; mkdir -p "UNITYEXTRACT/${DESTFILE%/*}"; mv "$SRC" "UNITYEXTRACT/$DESTFILE"' sh {} \;
find "$tmp" -name 'asset' -exec sh -c '
SRC="$1"
DESTFILE="$(cat "${SRC%/*}/pathname" | sed -E -e '\''s,^\.\./,,'\'' -e '\''s,/\.\./,/,g'\'')"
echo "$DESTFILE"
mkdir -p "UNITYEXTRACT/${DESTFILE%/*}"
mv -i "$SRC" "UNITYEXTRACT/$DESTFILE"
' sh {} \;
rm -rf "$tmp"