diff --git a/sync-music/sync-music.lisp b/sync-music/sync-music.lisp index f385a60..af3b8fd 100644 --- a/sync-music/sync-music.lisp +++ b/sync-music/sync-music.lisp @@ -84,10 +84,12 @@ Return the action if it exists, or NIL if the file should not be copied." data-raw) :for metadata-filtered := (delete-if (compose #'emptyp #'cdr) metadata) :for previous-action := nil :then current-action - :for output-file-name := (substitute #\! #\/ (format nil - "~A - ~A" - track-number - track-title)) + :for output-file-name := (ppcre:regex-replace-all *invalid-char-scanner* + (format nil + "~A - ~A" + track-number + track-title) + "!!!") :for current-action := (make-copy-flac-action :origin origin-file :target (pathname-normalize-unicode diff --git a/sync-music/utils.lisp b/sync-music/utils.lisp index 19d3b63..be76720 100644 --- a/sync-music/utils.lisp +++ b/sync-music/utils.lisp @@ -21,6 +21,9 @@ (defparameter *timestamp-scanner* (ppcre:create-scanner "^(\\d+):(\\d{2})\\.(\\d{2})$") "Scan for a cuetools position.") +(defparameter *invalid-char-scanner* (ppcre:create-scanner "[\"*/:<>?\\\\|]") + "Scan for any characters not allowed in an Android/NTFS file name.") + (defun maybe-normalize-unicode (s) (if (stringp s) (uax-15:normalize s :nfc) s))