name : update colors.

This commit is contained in:
Dmitry Voronin 2023-11-08 20:31:00 +03:00
parent 6a8c1b0ba0
commit 965539d9b1

View file

@ -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 <SEASON>"
echo "usage: name_series <SEASON> [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 <SEASON>"
echo "usage: name_manga <SEASON> [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
}