update
This commit is contained in:
32
tvshow_categorize_files
Executable file
32
tvshow_categorize_files
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# to categorize named files
|
||||
#
|
||||
|
||||
# Check if tvshow_categorize_name is available
|
||||
if ! command -v tvshow_categorize_name &> /dev/null; then
|
||||
echo "tvshow_categorize_name command not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find and process files
|
||||
find . -maxdepth 1 -type f -print0 | while IFS= read -r -d '' file; do
|
||||
# Get the name from tvshow_categorize_name
|
||||
NAME="$(tvshow_categorize_name "$file")"
|
||||
|
||||
# Check if the name was successfully retrieved
|
||||
if [[ -z "$NAME" ]]; then
|
||||
echo "Failed to categorize $file"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "$file -> $NAME"
|
||||
|
||||
# Create the directory if it doesn't exist
|
||||
if [[ ! -d "$NAME" ]]; then
|
||||
sudo mkdir -p "$NAME"
|
||||
fi
|
||||
|
||||
# Move the file to the categorized directory
|
||||
sudo mv "$file" "$NAME"
|
||||
done
|
||||
Reference in New Issue
Block a user