My first question on this stackexchange, and I am sure there will be more as I venture farther into the world of what is Linux...
I have a for-loop in a shell-script that batch renames all files to a substring (the last n characters) of its original name.
It will echo
every iteration on a new line to eventually produce a list of all files but how do I keep that echo on a single/updating line so it doesn't produce this (sometimes large) list?
echo "- Renaming file..."
for file in `find fldr -type f`
do
newf=$(echo $file | rev | cut -c -6 | rev)
mv -f $file fldr/$newpt
echo " * $file > $newf"
done
actual output...
- Renaming file...
* file1a.txt > 1a.txt
* file2a.txt > 2a.txt
* file3a.txt > 3a.txt
* ...
desired output...
- Renaming file...
* file3a.txt > 3a.txt
I would like to see the one line always changing to show the current file only.
[BONUS] How would I get it to also display the n'th file it is renaming?
- 3 files renamed...
* file3a.txt > 3a.txt
Where n is a cumulative sum/count of the files renamed.