Bash aliases are great, so is dired.
<p>I don't know why it took me so long to create this, but from here on out, it's going on all my machines and I'll use it a few times per week at work.</p> <pre><code>alias spaces2underscores='for i in *; do mv -iv "$i" "${i// /_}"; done' </code></pre> <p>Usage:</p> <pre><code>hobbes@metalbaby:~/projects/apache/20180119-brianna$ spaces2underscores renamed 'LHD Map Jan 2018.pdf' -> 'LHD_Map_Jan_2018.pdf' renamed 'Contacts List.xls' -> 'Contacts_List.xls' </code></pre> <p>Previously, I would do <code>emacs .</code> followed by <code>C-x C-q M-x replace-string SPC _ RET C-c C-c C-x C-c</code>, which accomplishes the same goal, and felt amazing when I did it to hundreds of files at a time. Of course, I'll still use this method if the replacement is more complex than <code>SPC -> _</code>...</p>
Related stories
- Knightmare: A DevOps Cautionary Taledougseven.comLobsters · 15 points · over 11 years ago
- Hacker News · 1 points · 2 days ago
- bash-completion for vim commandgithub.comLobsters · 11 points · over 5 years ago
- Hacker News · 2 points · 10 days ago
- Linux Implements Dynamic Bash Tab Completionsalivity.github.ioHacker News · 1 points · 7 days ago
- DTAP – check Linux servers infrastructure with Bashdtap.sparrowhub.ioHacker News · 1 points · 5 days ago