achive & name : add report for failed checks count.
This commit is contained in:
parent
fa4c85ade8
commit
84ccaddf26
|
@ -2,8 +2,8 @@
|
|||
archive()
|
||||
{
|
||||
local target="$@" # target file(s).
|
||||
local count=1
|
||||
local total=$#
|
||||
local count=1 # processed count.
|
||||
local total=$# # total to process.
|
||||
|
||||
# set dafult value to target all supported archives.
|
||||
if [[ "$target" = "" ]]; then
|
||||
|
@ -32,8 +32,8 @@ archive()
|
|||
archive_fast()
|
||||
{
|
||||
local target="$@" # target file(s).
|
||||
local count=1
|
||||
local total=$#
|
||||
local count=1 # processed count.
|
||||
local total=$# # total to process.
|
||||
|
||||
# set dafult value to target all supported archives.
|
||||
if [[ "$target" = "" ]]; then
|
||||
|
@ -64,8 +64,9 @@ archive_check()
|
|||
local target="$@" # target file(s).
|
||||
local saved # saved hash value.
|
||||
local actual # actual file hash value.
|
||||
local count=1
|
||||
local total=$#
|
||||
local count=1 # processed count.
|
||||
local total=$# # total to process.
|
||||
local failed=0 # total failed checks.
|
||||
|
||||
# set dafult value to target all supported archives.
|
||||
if [[ "$target" = "" ]]; then
|
||||
|
@ -89,12 +90,18 @@ archive_check()
|
|||
if [[ "$actual" = "$saved" ]]; then
|
||||
echo "${status}: OK."
|
||||
else
|
||||
echo "${status}: failed."
|
||||
echo -e "${color_red}${status}: failed.${color_default}"
|
||||
((failed++))
|
||||
fi
|
||||
|
||||
# increment counter.
|
||||
((count++))
|
||||
done
|
||||
|
||||
# report if any failed.
|
||||
if [[ ${failed} -gt 0 ]]; then
|
||||
echo -e "${color_bred}Items failed to validate: ${failed}.${color_default}"
|
||||
fi
|
||||
}
|
||||
|
||||
# extract previously created archive with checksum validation.
|
||||
|
@ -103,8 +110,8 @@ unarchive()
|
|||
local target="$@" # target file(s).
|
||||
local saved # saved hash value.
|
||||
local actual # actual file hash value.
|
||||
local count=1
|
||||
local total=$#
|
||||
local count=1 # processed count.
|
||||
local total=$# # total to process.
|
||||
|
||||
# set dafult value to target all supported archives.
|
||||
if [[ "$target" = "" ]]; then
|
||||
|
|
|
@ -121,33 +121,41 @@ name_hash_check()
|
|||
local files="$@"
|
||||
local count=1
|
||||
local total=$#
|
||||
local failed=0
|
||||
|
||||
# all files by default.
|
||||
if [[ "$files" = "" ]]; then
|
||||
files="[^.]*"
|
||||
total=$(ls -p | grep -v / | wc -l)
|
||||
fi
|
||||
|
||||
# process.
|
||||
for file in $files; do
|
||||
# process only files.
|
||||
if [[ -f "$file" ]]; then
|
||||
# status info.
|
||||
local status="[$count/$total] $file"
|
||||
|
||||
# extract hashes.
|
||||
stored="${file%%.*}"
|
||||
actual=$(sha1sum -- "$file" | cut -d\ -f1)
|
||||
|
||||
# compare hashes.
|
||||
echo -n "[$count/$total] $file: "
|
||||
if [[ "$stored" = "$actual" ]]; then
|
||||
echo "OK."
|
||||
echo -e "${status}: OK."
|
||||
else
|
||||
echo "failed."
|
||||
echo -e "${color_red}${status}: failed.${color_default}"
|
||||
((failed++))
|
||||
fi
|
||||
|
||||
# increment count.
|
||||
((count++))
|
||||
fi
|
||||
done
|
||||
|
||||
# report if any failed.
|
||||
if [[ ${failed} -gt 0 ]]; then
|
||||
echo -e "${color_bred}Items failed to validate: ${failed}.${color_default}"
|
||||
fi
|
||||
}
|
||||
|
||||
# rename files for Jellyfin series, i.e. Episode S01E01.mkv
|
||||
|
|
Reference in a new issue