Reputation: 22559
I downloaded a bunch on images using wget, and unfortunately, there was a huge drawback...
The downloaded images had the same name! So, the script automatically appended .1, .2 , ...etc. at the end:
Accept-Male-User-icon.png
Accept-Male-User-icon.png.1
Accept-Male-User-icon.png.2
...
So, am looking for a script that would take these files and rename them according to their size, given that their size could be one of the following:
(256x256, 128x128, 64x64, 48x48, 32x32, 16x16)
So I end up with something like this:
Accept-Male-User-icon256.png
Accept-Male-User-icon128.png
Accept-Male-User-icon64.png
...
Thanks!!
Upvotes: 4
Views: 1830
Reputation: 212835
If you have ImageMagick installed, you can try:
for a in *.png*; do mv -i $a ${a%\.png*}`identify -format '%w' $a`.png; done
Test it and if it works, remove the -i
switch after mv
.
Upvotes: 10
Reputation: 25596
pngcheck
, pnginfo
, or imageinfo --width --height
apt-get
or yum
newname=${filename%.*}
mv
Upvotes: 3