Question

i need a lot of files in one of my programs and to get them loaded in all in one line of code i would like to rename all of the files i need.

it are over 100 files so doing manualy isn't realy an option. the files are named vlc(random numbers).png and want to rename them to vlc(incrementing number).png

i already found how i can get all the needed files and rename them (see @ bottom) but i can't get an incrementing filenumber on the end, how can i get this?

clear; for f in vlc*.png; do echo $f ${f/vlc*/vlc}; done

Was it helpful?

Solution

here is how you can do it and it works:

copy the code under these lines and name the file rename.sh, then all you need to do is make it so that you can run the script and then run it useig ./rename.sh

#!/bin/bash
#
# Author: 
# rename script
# rename.sh
x=0;
for filename in *.png
do
echo $filename;
x=`expr $x + 1`;
echo $x.png; 
mv $filename $x.png;
done
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top