Pan/0.135 (Tomorrow I'll Wake Up and Scald Myself with Tea; GIT 30dc37b master)
On Wed, 11 Apr 2012 15:44:26 -0500, lxnf98mm-Re5JQEeQqe8AvxtiuMwx3w wrote:
> I have many files, 2.5 million, that I have to make available to Windows
> folks They demand that the files have a extension added Is there an
> efficient method of bulk renaming files
>
> Richard
My instinctive response to this question would be to use the find
command, or perhaps a list of filenames that you've already generated
somehow.
First case:
find <root-dir-of-search> -type f -name "*some-pattern*" -print0 |
xargs -0 -I@ mv "@" "@.ext"
or
find <root-dir-of-search> -type f -name "*some-pattern*" |
while read
do
mv "$REPLY" "$REPLY.ext"
done
Sometimes, it seems, using the while loop instead of xargs is faster.
Second case:
while read
do
mv "$REPLY" "$REPLY.ext"
done < file-list
Of course, there are other ways, but these are my most commonly used
idioms.
--
Conrad J. Sabatier
address@hidden