Help with this script
Im trying to grab the jpg and rename it accord to ls. what do i need to do to get this working? ls will list a bunch of .htm files
Quote:
|
Hi,
have a look at the following threads first: http://www.linuxquestions.org/questi...-files-831347/ http://www.linuxquestions.org/questi...lename-827305/ http://www.linuxquestions.org/questi...olders-804100/ http://www.linuxquestions.org/questi...751/page2.html Renaming files is a common task and it has been covered several times now. There is probably something in the links above that will solve your problem. Post again if you have trouble understanding a command. [EDIT] Just saw that you are using wget. Are you trying to keep a local directory in sync with the contents of a webpage? Please provide some sample filenames and how you want them to rename. |
Well I am a little concerned with the whole script!!
Code:
list=`ls` Code:
for i in `cat $list | grep productpic |sed -e 's/ //g'| sed -e 's/.*productpic//' | sed -e 's/jpg.*//' | sed 's/[.]/.jpg/g'` Code:
wget "http://www.digi163.com/battery/productpic$i" > $list Not only that, but you went to all the trouble of avoiding word splitting for your for loop but then didn't quote this variable so here it is again?? Let us go back to some basics: 1. What does the directory structure look like where you are running ls? 2. Provide at least one complete url (can be fake) so we understand what you are wgetting? 3. What do you wish to be the contents of the file and of what file? |
I'm assuming there is directory containing files such as
HP-HSTNN-LB31-battery.htm from downloading http://www.digi163.com/battery/HP-la...31-battery.htm and you want to extract the jpg relative URL from the htm file, download the jpg file, and save it as HP-HSTNN-LB31-battery.jpg. Code:
#!/bin/bash |
@OP, how is your htm files being downloaded in the first place? With wget, you can also download those image files.
|
All times are GMT -5. The time now is 03:08 PM. |