add script cleanup addon
This commit is contained in:
parent
085ec904e6
commit
1987d08b9d
49
setup/clean_up_addon.sh
Normal file
49
setup/clean_up_addon.sh
Normal file
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if a root folder is provided as an argument
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 <root_folder>"
|
||||
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
|
Loading…
Reference in New Issue
Block a user