From a2a427c0bec1401ca25f38f8e62683afaf251cce Mon Sep 17 00:00:00 2001 From: Drazzilb <65743746+Drazzilb08@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:47:47 -0700 Subject: [PATCH 1/3] Doc: update info for nohl_bash --- config/config.sample.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/config.sample.yml b/config/config.sample.yml index 1d21b67..0cb5d48 100755 --- a/config/config.sample.yml +++ b/config/config.sample.yml @@ -314,7 +314,6 @@ poster_cleanarr: ignore_collections: - "Random Collection in assets you want to keep" # If using poster_renamer with border_replacer, include the tmp folder that border_replacer uses - # This will double output in the logs but source_dirs: - /path/to/assets @@ -454,6 +453,8 @@ bash_scripts: include: - - + # Exclude certain movie/series folders from being searched + # NOTE: It must be exactly as the folder is listed in your file system exclude: - - From 5f217f19d8ef31a2b3f53f7fa1fd827e0436ed9c Mon Sep 17 00:00:00 2001 From: Drazzilb <65743746+Drazzilb08@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:48:01 -0700 Subject: [PATCH 2/3] bug fix: nohl_bash respect exclusion list --- scripts/nohl_bash.sh | 55 +++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/scripts/nohl_bash.sh b/scripts/nohl_bash.sh index e8ea6f8..07c7452 100755 --- a/scripts/nohl_bash.sh +++ b/scripts/nohl_bash.sh @@ -12,25 +12,6 @@ # License: MIT License # ==================================================== -# Define variables -source_dir='/path/to/media/' -log_dir='' - -# Define folders inside your source_dir to include in the search -include=( - #"Media directories" - #"Movies" - #"TV Shows" - #"Anime" -) - -# Define folders inside your source_dir to exclude from the search -exclude=( - #"Show Name" - #"Show Name" - #"Show Name" -) - # Define variables for webhook notifications webhook=false webhook='' @@ -101,7 +82,7 @@ log_file() { if [ -n "$DOCKER_ENV" ]; then log_dir="${LOG_DIR/nohl_bash:-$parent_dir/logs/nohl_bash}" else - log_dir="${log_dir:-$parent_dir/logs/nohl_bash}" + log_dir="${log_dir:-$parent_dir/logs}" fi # remove trailing slash from source_dir if it exists source_dir=${source_dir%%/} @@ -144,12 +125,32 @@ check_hardlinks() { # Construct the find command to search for files with hard link count of 1 # Exclude folders listed in 'exclude_folders' and 'exclude' # Include specific file extensions listed in 'file_extensions' - find "${source_dir}/${include[$i]}" -type d \( -name "${exclude_folders[*]}" -o -name "${exclude[*]}" \) -prune -o -type f -links 1 \( -iname "*.${file_extensions[0]}" -o -iname "*.${file_extensions[1]}" -o -iname "*.${file_extensions[2]}" -o -iname "*.${file_extensions[3]}" -o -iname "*.${file_extensions[4]}" -o -iname "*.${file_extensions[5]}" \) -printf "%P\n" | tee -a "$log_file" - # Use awk and sed to remove unwanted characters from the file name and print it to /tmp/nohl.tmp - find "${source_dir}/${include[$i]}" -type d \( -name "${exclude_folders[*]}" -o -name "${exclude[*]}" \) -prune -o -type f -links 1 \( -iname "*.${file_extensions[0]}" -o -iname "*.${file_extensions[1]}" -o -iname "*.${file_extensions[2]}" -o -iname "*.${file_extensions[3]}" -o -iname "*.${file_extensions[4]}" -o -iname "*.${file_extensions[5]}" \) -printf "%f\n" | awk -F"[" '{print $1}' | sed $'s/[^[:print:]\t]//g' | tee -a /tmp/nohl.tmp >/dev/null - done + find_command="find \"$source_dir/${include[$i]}\" -type f -links 1 \( " + + for l in "${file_extensions[@]}"; do + find_command+=" -name '*.$l' -o" + done + + # Remove the trailing '-o' from the find command and close the parentheses + find_command=${find_command%-o} + find_command+=" \)" + for j in "${exclude_folders[@]}"; do + find_command+=" -not -path '*/$j/*'" + done + + for k in "${exclude[@]}"; do + find_command+=" -not -path '*/$k/*'" + done + + # Print the find command to the console + # echo "Find command: $find_command" | tee -a "$log_file" + + # Execute the find command and store the output in a temporary file + eval "$find_command" > /tmp/nohl.tmp + eval "$find_command" | tee -a "$log_file" + done } # Function to send notification @@ -331,6 +332,12 @@ handle_options() { :) echo "Option -$OPTARG requires an argument." >&2; display_help; exit 1 ;; esac done + # Update exclude array with -e option + # Add string to exclude array seperated by comma + # shellcheck disable=SC2128 + if [ -n "$exclude" ]; then + IFS=',' read -r -a exclude <<< "$exclude" + fi } # Call the function From fa9d5cbeabdb4e48e6bae2af6975c6a27bdf7f1a Mon Sep 17 00:00:00 2001 From: Drazzilb <65743746+Drazzilb08@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:48:08 -0700 Subject: [PATCH 3/3] v0.1.13 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 6a36bb4..45263ab 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.12 \ No newline at end of file +0.1.13 \ No newline at end of file