Recursively rename files - oneliner preferably
Posted
by
zetah
on Ask Ubuntu
See other posts from Ask Ubuntu
or by zetah
Published on 2011-11-18T12:24:28Z
Indexed on
2012/10/06
3:50 UTC
Read the original article
Hit count: 354
bash
I found this answer how do i... but it simply doesn't work - it did not rename any file for unknown to me reason
Before I started to search around I thought that it should be easy task even for novice penguin, but it doesn't seem so for me.
For example, I simply can't tell ls
to list all *.txt
in all subfolders, which was surprise to me (without grep or similar).
Then I found find
and find . -name name_1.txt
lists files fine, but
for f in $(find . -name name_1.txt) ; do echo "$f" ; done
splits whole file paths with space as separator, so it's unusable to pass that output to some command like mv
or rename
I want to ask whats wrong with above command and if possible some nifty oneliner so I can recursively rename name_1.txt
to name_2.txt
© Ask Ubuntu or respective owner