Download images from the first column and rename it with the second column in a loop: Please help! | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

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

Shell Programming and Scripting


Tags
download images and rename

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-21-2013
Praveen Pandit Praveen Pandit is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 4 November 2014, 4:34 AM EST
Location: Bangalore
Posts: 23
Thanks: 12
Thanked 0 Times in 0 Posts
Question 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


Code:
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

Last edited by Scrutinizer; 01-21-2013 at 05:34 AM.. Reason: code tags
Sponsored Links
    #2  
Old 01-21-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 17 December 2014, 4:49 PM EST
Location: Galactic Empire
Posts: 3,395
Thanks: 240
Thanked 1,211 Times in 1,137 Posts
Use --output-document option with wget to specify the file name while downloading:

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

Sponsored Links
    #3  
Old 01-23-2013
Praveen Pandit Praveen Pandit is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 4 November 2014, 4:34 AM EST
Location: Bangalore
Posts: 23
Thanks: 12
Thanked 0 Times in 0 Posts
Thanks lot for help !!

Thanks lot for help !!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Rename a header column by adding another column entry to the header column name Vavad UNIX for Dummies Questions & Answers 1 08-06-2011 02:02 PM
Rename a header column by adding another column entry to the header column name URGENT!! Vavad Shell Programming and Scripting 4 08-05-2011 01:35 PM
loop in awk - column max for each column irrevocabile Shell Programming and Scripting 3 03-12-2011 05:54 PM
Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 rydz00 Shell Programming and Scripting 7 11-09-2010 11:28 AM
Changing one column of delimited file column to fixed width column manneni prakash Shell Programming and Scripting 5 06-22-2009 06:27 AM



All times are GMT -4. The time now is 03:14 AM.