Hi,
I have many files like below in my currect dir
test1.me
test3.me
I wanted them to rename without .me extention
I tried below
find . -name "*.me" | xargs -i mv {} `echo {} | sed 's/\.me//'`
It thorws error that
cant mv ./test1.me to ./test1.me as they are identical
Not sure why `echo {}|sed 's/\.me//'` is not working , or may be xargs is looking for the place holder ({})
Please help
Thanks
Sunny
Try:
for i in *.me; do
mv "$i" "${i%.me}"
done
worked,
but how to do it with xargs
xargs -i mv {} {%.me} ?? ,
it dint work
Scott
4
find . -name "*.me" | sed "p;s/\.me$//" | xargs -n2 mv
(if your filenames don't have spaces)
find . -name "*.doc" | sed 's/.*/"&"/;p;s/\.doc//' | xargs -L2 mv
(if they do)
Or if you want to rename every .me in every sub directory too:
find . -name "*.me" |
while read i; do
mv "$i" "${i%.me}"
done
tange
6
It is easy if you have GNU Parallel installed:
find . -name "*.me" | parallel mv {} {.}
If we're listing third-party nonstandard app solutions now, it's also easy with mmv:
mmv "*.me" "#1"