diff --git a/setup/clean_up_addon.sh b/setup/clean_up_addon.sh new file mode 100644 index 000000000..034e82044 --- /dev/null +++ b/setup/clean_up_addon.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Check if a root folder is provided as an argument +if [ -z "$1" ]; then + echo "Usage: $0 " + echo "Please provide a root folder path." + exit 1 +fi + +# Assign the input root folder to a variable +ROOT_FOLDER="$1" + +# Check if the root folder exists and is a directory +if [ ! -d "$ROOT_FOLDER" ]; then + echo "Error: '$ROOT_FOLDER' is not a valid directory." + exit 1 +fi + +# Function to check and delete subfolders +delete_non_manifest_folders() { + local dir="$1" + + # Loop through all immediate subdirectories in the given directory + for subfolder in "$dir"/*/ ; do + # Check if it's a directory + if [ -d "$subfolder" ]; then + # Check if __manifest__.py exists in this subfolder + if [ ! -f "$subfolder/__manifest__.py" ]; then + echo "Deleting '$subfolder' (no __manifest__.py found)" + rm -rf "$subfolder" + else + echo "Keeping '$subfolder' (__manifest__.py found)" + fi + fi + done +} + +# Change to the root folder to handle relative paths cleanly +cd "$ROOT_FOLDER" || { + echo "Error: Could not change to directory '$ROOT_FOLDER'" + exit 1 +} + +# Call the function with the root folder +delete_non_manifest_folders "." + +echo "Cleanup complete!" + +exit 0 \ No newline at end of file