Skip to content

Instantly share code, notes, and snippets.

@koturn
Created May 8, 2024 14:46
Show Gist options
  • Save koturn/6f03a18dfce42a7ac33b5c05fe21abed to your computer and use it in GitHub Desktop.
Save koturn/6f03a18dfce42a7ac33b5c05fe21abed to your computer and use it in GitHub Desktop.
unitypackageを展開するbashスクリプト
#!/bin/bash
set -eu
if [ $# -lt 1 ]; then
echo Invalid arguments 1>&2
echo [USAGE]
echo $0 UNITYPACKAGE
exit 1
fi
packagefile="$1"
dstdir=${packagefile%.*}
echo ${packagefile}
echo ${dstdir}
[ ! -d "${dstdir}" ] && mkdir ${dstdir} || :
\tar zxvf $1 -C "${dstdir}"
cd ${dstdir}
for pathfile in $(find . -type f -name 'pathname'); do
guiddir=${pathfile%/*}
pathname=$(\cat "${pathfile}")
assetdir=${pathname%/*}
echo "${guiddir#*/} -> ${pathname}"
\mkdir -p "${assetdir}"
[ -f "${guiddir}/asset" ] && \mv "${guiddir}/asset" "${pathname}" || :
[ -f "${guiddir}/asset.meta" ] && \mv "${guiddir}/asset.meta" "${pathname}.meta" || :
done
for pathfile in $(find . -type f -name 'pathname'); do
guiddir=${pathfile%/*}
\rm -rfv "${guiddir}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment