Created
May 8, 2024 14:46
-
-
Save koturn/6f03a18dfce42a7ac33b5c05fe21abed to your computer and use it in GitHub Desktop.
unitypackageを展開するbashスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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