Download images from the first column and rename it with the second column in a loop: Please help!

Dear Friends,

I have a very little knowledge on shell scripting. I am stuck with a problem for which I need an expert advice.

I have a .txt file "image_urls.txt" which contains the data like this

imageurl                                                                                     
 -------------------------------------------------------------------------------------------- 
 photos.ecarlist.com/Jl/8V/wM/lf/rR/vh/Vr/b0/EE/5C/dQ_640.jpg|KMHDC8AEXBU087303_1.jpg| 
 photos.ecarlist.com/Ow/MN/M7/qn/oD/zo/hJ/nw/m9/WF/PA_640.jpg|KMHDC8AEXBU087303_2.jpg| 
 photos.ecarlist.com/4d/HO/73/Jb/61/pE/Ru/uL/JB/Nb/gQ_640.jpg|KMHDC8AEXBU087303_3.jpg| 
 photos.ecarlist.com/7K/ve/VF/XQ/fn/Bn/SX/9R/T2/nj/eA_640.jpg|KMHDC8AEXBU087303_4.jpg| 
 photos.ecarlist.com/vp/Ig/sz/IH/T6/BF/EP/U3/0x/wB/zQ_640.jpg|KNADE223296557487_1.jpg| 
 photos.ecarlist.com/n2/2d/mZ/ex/dx/nG/Bd/z2/hW/Bm/8g_640.jpg|KNADE223296557487_2.jpg| 
 photos.ecarlist.com/JU/Ga/X0/io/ik/sr/uL/ku/z3/kB/ag_640.jpg|KNADE223296557487_3.jpg| 
 photos.ecarlist.com/ba/1o/jo/Jb/aN/8Y/z5/IX/q1/rG/lQ_640.jpg|KNADE223296557487_4.jpg| 

(h t t p urls above)

Since the images names are not unique they are getting overwritten as soon as its downloaded. So I want to rename the images in first column with the second column value (vin_series) in a loop (line by line), one by one image.

The renamed images will be there in the directory and mapped in the database.

Please help me on this.

Regards
Praveen

Use --output-document option with wget to specify the file name while downloading:

while IFS="|" read url img skip
do
  [[ ! -z "$img" ]] && wget --output-document="${img}" "${url}"
done < image.urls.txt

Thanks lot for help !!