Skip to content

Instantly share code, notes, and snippets.

@R3D9477
Created March 29, 2021 22:27
Show Gist options
  • Save R3D9477/fc5bd2991123e64f1bcd5af8717231bb to your computer and use it in GitHub Desktop.
Save R3D9477/fc5bd2991123e64f1bcd5af8717231bb to your computer and use it in GitHub Desktop.
Rename Unreal Engine's project file: $ rename_uproject.sh "/path/to/your_project.uproject" "new_name"
#!/bin/bash
if ! [ -f "$1" ] ; then exit 1 ; fi
if [ "$2" == "" ] ; then exit 2 ; fi
FULL_PATH=$(realpath "$1")
DIR_NAME=$(dirname "${FULL_PATH}")
FILE_NAME=$(basename -- "${FULL_PATH}")
BASE_NAME="${FILE_NAME%.*}"
pushd "${DIR_NAME}"
pushd "Config"
for f in *.ini ; do
sed -i "s/${BASE_NAME}/$2/g" "${f}"
if [[ "${f}" =~ "${BASE_NAME}" ]] ; then
NEW_F=$(echo "${f}" | sed "s/${BASE_NAME}/$2/g")
mv "${f}" "${NEW_F}"
fi
done
popd
mv "$1" "$2.uproject"
rm -rf "DerivedDataCache"
rm -rf "Intermediate"
rm -rf "Binaries"
rm -rf "Build"
rm -rf "Out"
popd
if [ "$PWD" != "$DIR_NAME" ] ; then
NEW_DIR=$(echo "${DIR_NAME}" | sed "s/${BASE_NAME}/$2/g")
if [ "$NEW_DIR" != "$DIR_NAME" ] ; then
mv "${DIR_NAME}" "${NEW_DIR}"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment