License GNU General Public License, version 2
Lines 16
Keywords
emacs dired file rename (1)
Permissions
Owner: billalex
Viewable by Everyone
Editable by billalex's Friends
Hide
Don't get spied on – We respect your privacy and provide numerous options to protect it. Join Siafoo Now or Learn More

emacs dired rename file by removing blanks Atom Feed 0

In Brief Rename files to remove blanks. Reason for use: blanks in files mess up some unix utilities.
# 's
 1;;This is written in eLisp, a language not in the siafoo pull-down:
2
3(defun ba-dired-file-cleanup-blanks ()
4 "Rename a file by converting each blank to underscore
5and each _*-_* to a dash"
6 (interactive)
7 (if (not (or (string= mode-name "Dired by name")
8 (string= mode-name "Dired by date")))
9 (message "must be in dired mode")
10 (dired-previous-line 1)
11 (dired-next-line 1)
12 (let* ((org-name (buffer-substring-no-properties
13 (point) (line-end-position)))
14 (blank-free-name (replace-regexp-in-string " " "_" org-name))
15 (new-name (replace-regexp-in-string "_*-_*" "-" blank-free-name)))
16 (rename-file org-name new-name t)
17 (dired-revert))))

Rename files to remove blanks. Reason for use: blanks in files mess up some unix utilities.