I want to rename all files in a folder and add a .xml
extension. I am using Unix. How can I do that?
On the shell, you can do this:
for file in *; do
if [ -f ${file} ]; then
mv ${file} ${file}.xml
fi
done
Edit
To do this recursively on all subdirectories, you should use find
:
for file in $(find -type f); do
mv ${file} ${file}.xml
done
On the other hand, if you're going to do anything more complex than this, you probably shouldn't use shell
scripts.
Better still
Use the comment provided by Jonathan Leffler below:
find . -type f -exec mv {} {}.xml ';'
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments