I am trying to remove file extension 'log' by practice:
find -name "*.log" | xargs -t -I {} mv {} {{}%.log}
I would probably just use rename
:
find -name '*.log' | xargs rename .log ''
Or a shell script:
find -name '*.log' | while read f; do mv $f ${f%.log}; done
If you are using bash
4 or later, you can simply use
shopt -s globstar
for f in **/*.log; do
mv -- "$f" "${f%.log}"
done
Otherwise, use find
to execute a shell whose argument is the file to rename; this allows you to use parameter expansion to strip the extension.
find -name '*.log' -exec sh -c 'mv -- "$1" "${1%.log}"' {} \;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With