Renaming batch of files (with spaces) in linux
Published on Sep 28, 2013, 10:26 PM1 min read
I rename a lot of files. Often by hand as it's just easier. I've tried various combinations of find -print0 | xargs -0, and find -exec, without much luck.
Just So I have reference on what does work:
find -type f | while read file; do echo mv \"$file\" \"$(echo $file | sed -e 's/^Old Content/New Content/')\"; done | sh
Yea I could probably drop the echo mv, and the |sh, but it feels safer to do a dry run

Gavin Mogan
I'm Gavin.
I'm a tinker, maker, and software developer.
At home I code, game, hang out, all the cool non robot things to do.
Heavily involved with Jenkins open source, and will often submit PRs to random other projects.
I also play games, both board and video games and love to read.
You can usually find me on various services as halkeye.
#notarobot
Comments