X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/48dab430af0eb368f87d6e26eb7a7afa8b728a60..6902250a188de0d54be60ac9f2d7075c37176b01:/user/bk-copy-rand-music?ds=inline

diff --git a/user/bk-copy-rand-music b/user/bk-copy-rand-music
index bc21e5b..b807286 100644
--- 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