Subject: Re: bug#24620: 26.0.50; In dired: 'dired-do-compress-to' fails when filenames cotains space characters

From: José L. Doménech<[email-masked]>
Date: Thu, 27 Oct 2016 16:03:47 +0200

I wrote a little patch to get a workaround around dired having some trouble compressing files with space characters in its name (bug #24620).

I am not sure if this will useful to someone. Please NOTE that I am using apostrophes to surround the file name's. While it works on my system (GNU/Linux) it could not work on other systems.

Best Regards:
José L. Doménech

diff -u dired-aux.el dired-aux-mod.el
--- dired-aux.el	2016-10-27 15:50:50.428634418 +0200
+++ dired-aux-mod.el	2016-10-27 15:49:07.075635431 +0200
@@ -974,10 +974,10 @@
 ARGS are command switches passed to PROGRAM.")
 
 (defvar dired-compress-files-alist
-  '(("\\.tar\\.gz\\'" . "tar -c %i | gzip -c9 > %o")
-    ("\\.tar\\.bz2\\'" . "tar -c %i | bzip2 -c9 > %o")
-    ("\\.tar\\.xz\\'" . "tar -c %i | xz -c9 > %o")
-    ("\\.zip\\'" . "zip %o -r --filesync %i"))
+  '(("\\.tar\\.gz\\'" . "tar -c %i | gzip -c9 > '%o'")
+    ("\\.tar\\.bz2\\'" . "tar -c %i | bzip2 -c9 > '%o'")
+    ("\\.tar\\.xz\\'" . "tar -c %i | xz -c9 > '%o'")
+    ("\\.zip\\'" . "zip '%o' -r --filesync %i"))
   "Control the compression shell command for `dired-do-compress-to'.
 
 Each element is (REGEXP . CMD), where REGEXP is the name of the
@@ -1015,7 +1015,9 @@
                    (replace-regexp-in-string
                     "%o" out-file
                     (replace-regexp-in-string
-                     "%i" (mapconcat #'file-name-nondirectory in-files " ")
+                     "%i" (mapconcat (lambda (file-desc)
+                                       (concat "'"
+                                               (file-name-nondirectory file-desc) "'")) in-files " ")
                      (cdr rule)))))
              (message "Compressed %d file(s) to %s"
                       (length in-files)

Diff finished.  Thu Oct 27 15:53:44 2016