From 965539d9b1cde5649779c9d995707bec6b7dcd95 Mon Sep 17 00:00:00 2001 From: desktop Date: Wed, 8 Nov 2023 20:31:00 +0300 Subject: [PATCH] name : update colors. --- .linux/bash/module/name.sh | 68 ++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/.linux/bash/module/name.sh b/.linux/bash/module/name.sh index f7f43cf..20f8a59 100644 --- a/.linux/bash/module/name.sh +++ b/.linux/bash/module/name.sh @@ -26,7 +26,11 @@ name() ext=".${target##*.}" name="${target%.*}" fi + + # Files w/o extension support. + [[ "${ext#.}" = "${name}" ]] && ext="" + # Get new name. local new_name=$(parse_simplify "${name}")${ext} # status line. @@ -34,13 +38,13 @@ name() # check if same name. if [[ "${target}" = "${new_name}" ]]; then - echo -e "${color_green}${status}: no change.${color_default}" + echo -e "${color_yellow}${status}: No change.${color_default}" continue fi # check if target name already exists. if [[ -f "${new_name}" ]]; then - echo -e "${color_red}${status}: already exists!${color_default}" + echo -e "${color_bred}${status}: already exists!${color_default}" return 1 fi @@ -48,7 +52,7 @@ name() mv -- "${target}" "${new_name}" &> /dev/null # show change. - echo "${status}" + echo -e "${color_green}${status}${color_default}" done } @@ -90,7 +94,7 @@ name_hash() # check if same name. if [[ "${target}" = "${new_name}" ]]; then - echo -e "${color_green}${status}: no change.${color_default}" + echo -e "${color_yellow}${status}: No change.${color_default}" continue fi @@ -98,13 +102,13 @@ name_hash() mv -- "${target}" "${new_name}" &> /dev/null # show change. - echo -e "${status}" + echo -e "${color_green}${status}${color_default}" else # Increment count. ((count++)) # Report skip. - echo -e "${color_yellow}[${count}/${total}] ${target}: skipping directory.${color_default}" + echo -e "${color_yellow}[${count}/${total}] ${target}: Skipping directory.${color_default}" fi done } @@ -140,9 +144,9 @@ name_hash_check() # compare hashes. if [[ "${stored}" = "${actual}" ]]; then - echo -e "${status}: OK." + echo -e "${color_green}${status}: Validation OK.${color_default}" else - echo -e "${color_red}${status}: failed.${color_default}" + echo -e "${color_bred}${status}: Validation failed.${color_default}" ((failed++)) fi else @@ -150,7 +154,7 @@ name_hash_check() ((count++)) # Report skip. - echo -e "${color_yellow}[${count}/${total}] ${target}: skipping directory.${color_default}" + echo -e "${color_yellow}[${count}/${total}] ${target}: Skipping directory.${color_default}" fi done @@ -176,7 +180,7 @@ name_series() # error when no season number specified. if [[ "${season}" = "" ]]; then - echo "usage: name_series " + echo "usage: name_series [FILES]" return 1 fi @@ -200,15 +204,23 @@ name_series() # prepare status. local status="[${count}/${total}] ${target} -> ${new_name}" + # Warning on no change. + if [[ "${target}" = "${new_name}" ]]; then + echo -e "${color_yellow}${status}: No change.${color_default}" + continue + fi + # rename target. mv -- "${target}" "${new_name}" &> /dev/null - echo -e "${status}" + + # Report status. + echo -e "${color_green}${status}${color_default}" else # Increment count. ((count++)) # Report skip. - echo -e "${color_yellow}[${count}/${total}] ${target}: skipping directory.${color_default}" + echo -e "${color_yellow}[${count}/${total}] ${target}: Skipping directory.${color_default}" fi done } @@ -226,7 +238,7 @@ name_manga() # error when no season number specified. if [[ "${season}" = "" ]]; then - echo "usage: name_manga " + echo "usage: name_manga [FILES]" return 1 fi @@ -250,15 +262,23 @@ name_manga() # prepare status. local status="[${count}/${total}] ${target} -> ${new_name}" + # Warning on no change. + if [[ "${target}" = "${new_name}" ]]; then + echo -e "${color_yellow}${status}: No change.${color_default}" + continue + fi + # rename target. mv -- "${target}" "${new_name}" &> /dev/null - echo -e "${status}" + + # Show status. + echo -e "${color_green}${status}${color_default}" else # Increment count. ((count++)) # Report skip. - echo -e "${color_yellow}[${count}/${total}] ${target}: skipping directory.${color_default}" + echo -e "${color_yellow}[${count}/${total}] ${target}: Skipping directory.${color_default}" fi done } @@ -297,17 +317,23 @@ name_ext() # Prepare status. local status="[${count}/${total}] ${target} -> ${new_name}" + # Warning on no change. + if [[ "${target}" = "${new_name}" ]]; then + echo -e "${color_yellow}${status}: No change.${color_default}" + continue + fi + # rename target. mv -- "${target}" "${new_name}" &> /dev/null # show change. - echo "${status}" + echo -e "${color_green}${status}${color_default}" else # Increment count. ((count++)) # Report skip. - echo -e "${color_yellow}[${count}/${total}] ${target}: skipping directory.${color_default}" + echo -e "${color_yellow}[${count}/${total}] ${target}: Skipping directory.${color_default}" fi done } @@ -338,12 +364,18 @@ name_prefix() # Prepare status. local status="[${count}/${total}] ${target} -> ${new_name}" + + # Warning on no change. + if [[ "${target}" = "${new_name}" ]]; then + echo -e "${color_yellow}${status}: No change.${color_default}" + continue + fi # Rename. mv -- "${target}" "${new_name}" &> /dev/null # Show change. - echo "${status}" + echo -e "${color_green}${status}${color_default}" done }