How to append “.backup” to the name of each file in your current directory?
Asked
Active
Viewed 3,660 times
3 Answers
4
If you have files with special characters and/or sub directories you should use:
find . -maxdepth 1 -type f -exec mv {} {}.backup \;

Timo
- 6,332
0
With a POSIX shell:
for file in *;do
[ -f "$file" ] && mv -- "$file" "$file.backup"
done
With perl
's rename
:
rename -- '-f && s/\Z/.backup/' *

Stéphane Chazelas
- 544,893

Joseph R.
- 39,549
zsh
). – Stéphane Chazelas Feb 09 '14 at 16:03