Progrider

Programming discussion

Board index
Help · ✓ Resolved

rename thousands of files, spaces to underscores

Is there a one liner? They're all in one directory.

3 replies

for f in *\ *; do mv -- "$f" "${f// /_}"; done That's bash. Run it with echo in front of mv first.
rename 's/ /_/g' * if you've got the Perl one. On Debian that's the rename package. The util-linux rename on some other distros has different arguments, and I've seen that catch people out.
bash one worked. thanks

Discussion resolved

This discussion is resolved. Its creator can reopen it to accept more replies.