zmv
does not read from standard input.
I would probably use find
with mv
here, or zmv
with a zsh
filename glob, but not both, and without involving grep
at all. Using grep
should be done on text that is divided into lines, not filenames (which could potentially include embedded newlines).
With filename globs (will only act on the current directory, and only on non-hidden files):
zmv '^TFLM *' 'TFLM $f'
Recursively, not renaming directories, including hidden files and files in hidden directories like find
would:
zmv '(**/)(^TFLM *)(#qD^/)' '${1}TFLM $2'
With find
(but without the conflict handling of zmv
, so adding a -i
option for safety):
find . ! -type d ! -name 'TFLM *' -exec sh -c '
for pathname do
mv -i "$pathname" "${pathname%/*}/TFLM ${pathname##*/}"
done' sh {} +
In bash
(for the current directory only, excluding hidden files):
shopt -s extglob
for name in !(TFLM *); do
mv -i -- "$name" "TFLM $name"
done
Or, in bash
with the Perl rename
utility:
shopt -s extglob
rename 's|/|/TFLM |' ./!(TFLM *)
(without the ./
, some variants would fail if there were file names starting with -
. Not all variants support --
to mark the end of options).