X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/1f725176a1e8319ebdcadb05ade95d9eb86b08c7..65207f302c1787df989174cebd4e383ef72eda19:/user/bk-copy-rand-music?ds=sidebyside diff --git a/user/bk-copy-rand-music b/user/bk-copy-rand-music old mode 100644 new mode 100755 index bc21e5b..b807286 --- a/user/bk-copy-rand-music +++ b/user/bk-copy-rand-music @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Desc: Copies random audio files # Usage: bk-copy-rand-music [dir SOURCE] [dir DEST] [int DURATION] ([int BYTES]) -# Version: 0.1.1 +# Version: 0.2.0 # Depends: BK-2020-03: bkshuf v0.1.0 declare -Ag appRollCall # Associative array for storing app status @@ -516,13 +516,15 @@ main() { fpath="$(printf "%s" "$line" | cut -d',' -f3-)"; ## Get basename of path file_basename="$(basename "$fpath")"; + ### Get basename without unprintable non-ASCII characters + file_basename_compat="$(printf "%s" "$file_basename" | tr -dc '[:graph:][:space:]' )"; ## Get 16-character b2sum fingerprint (for different files that share basename) fingerprint="$(b2sum -l32 "$fpath" | awk '{print $1}' )"; ## Form output filename num="$(printf "$num_fmt" "$n")"; - file_name="$num"_"$fingerprint".."$file_basename"; + file_name="$num"_"$fingerprint".."$file_basename_compat"; file_name="${file_name:0:$max_filename_length}"; # Limit filename length (e.g. Windows has max of 255 characters) ## Form output path @@ -538,7 +540,7 @@ main() { printf "$log_fmt" "$num" "$fingerprint" "$fdur" "$fsize" "$fpath_can" >> "$path_log_output"; ((n++)); - unset file_basename path_output + unset file_basename file_basename_compat path_output; done < <(printf "%s\n" "${list_copy[@]}"); # Report total duration and size