Skip to main content
The Nameless Site

Renaming batch of files (with spaces) in linux

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

2023 Update: the rename package (actually the perl module File::Rename cli) makes this way easier, use rename tool don't use the ugly find above.