Solved

downloading images from URL links

Posted on 2011-03-03
10
449 Views
Last Modified: 2013-12-25
I have a database with images for each product.

the field for images is populated with urls for the images.

how can i download all the images from the urls?
ideally i would be able to choose what to name each image also.

is there a program or script i can run to do this?
0
Comment
Question by:gleverator
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35029851
You may want to click the "Request Attention" link and ask that the appropriate web zones get added to this Q.
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 35043541

what language are you coding in?  Php, coldfusion, asp...
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 35043544
try downloading Infranview, a well known free graphics viewer, editor, etc.  See this link:
          http://www.irfanview.com/
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 55

Accepted Solution

by:
Bill Prew earned 250 total points
ID: 35043776
Hard to be sure exactly what you are after, if you want real time download and display of the images in an application, or not.  Since you mentioned renaming images it sounds more like you might want to pull them all at once to a local location for the application to use.  If that is the case then take a look at the WGET free utility, it's great at pulling things from the web and storing local copies.

http://www.gnu.org/software/wget/

~bp
0
 
LVL 38

Expert Comment

by:BillDL
ID: 35044155
Yes there are some methods that you could adopt using a couple of 3rd-party programs, but it depends on several aspects that perhaps you can explain a little bit more about to see whether my proposed suggestion would be suitable for your needs:

1. Are you trying to run a script from WITHIN your Database, eg. using VBA Scripting?

2. Are you trying to run Perl, VBS, JavaScript from within a Web Page?

3. If neither, and an EXTERNALLY run script is what you are looking for, then do you have a text-based list of URLs that can be used as a "list file" for a script that does the image downloading?

4. Do the URLs contain any special characters or spaces in the file names?  The characters may have to be anticipated in advance for a batch scripted method, such as finding and replacing %20 in the target file name with spaces when saving the file locally.

The following assumes that:
1. You have a text-based "list file" of URLs, each one on a new line,
2. That the server's folders are accessible to a browser, ie. no 404.php files or default.htm files to deliberately stop image browsing,
3. That the suggested small, old, but still functional, 3rd-party program runs in your Operating System:

URL2File:
http://www.chami.com/free/url2file_wincon.html
Called from a batch file that parses a list file containing fully qualified URLs, you can download the images to a new or existing folder of choice and optionally rename them.  For example, the following batch file should function:

 
@echo off
SetLocal EnableDelayedExpansion
set LISTFILE=C:\Images\ImgList.txt
set SAVEFOLDER=C:\Images\Downloaded
set PROGEXE=C:\Program Files\URL2File\URL2FILE.EXE
set SUFFIX=_downloaded

for /f "tokens=* delims=" %%A in ('type listfile.txt ^| find /i ".jpg"') do (
    echo.
    set URL=%%A
    set FILE=%%~nA
    set NAME=%%~nxA
    set EXT=%%~xA
    set FILE=!FILE:http://=!
    set FILE=!FILE:/=,!
    set FILE=!FILE:%%20=?!
    set FILE=!FILE: =?!
    set FILE=!FILE:?= !
    echo Downloading File: !NAME!
    call "%PROGEXE%" -o 15 "!URL!" "%SAVEFOLDER%\!FILE!%SUFFIX%!EXT!"
    echo. 
)
pause

Open in new window

0
 
LVL 38

Expert Comment

by:BillDL
ID: 35044161
Hi Bill.  I see we were thinking along the same lines as we tried to interpret gleverator's exact needs.  I went away for something to eat and came back, hence the delay in posting.  I hadn't read your suggestion.
0
 
LVL 55

Expert Comment

by:Bill Prew
ID: 35044204
It's all good Bill.

~bp
0
 
LVL 38

Expert Comment

by:BillDL
ID: 35044226
gleverator

In case you do test my suggested batch file, be aware of the following:

1. It is set to search the listfile for URLs that have their target as .JPG files.  That can probably be changed easily enough.

2. If browsing to the web server folder is prevented using a simple method like a 404.php or default.htm file in that folder. then URL2File will download whatever it sees in that folder, which could be the HTM or other file.  The file is saved as whatever the file extension of the called URL was, even though it is not an image file.

3. To use it, just modify the paths in the   set=   lines in the upper part of the batch file before the FOR loop.  Don't modify any other contents unless it doesn't work and you know why and how.

4. If at first the URL2File commands fail, you can run the program with switches that allow debugging:
-d = Enable debug mode.  Display warnings and other miscellaneous information.  Must be specified before other parameters.
-h = Display web server's response headers.
-o n = Timeout value in seconds (n) before aborting.
There are switches for sending a user name and password, proxy details, and a few others to look at also if required.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Add visuals to your Prezi to keep your audience engaged. Learn how to embed images, edit them, and more in this video micro tutorial. Select "Insert" from the top menu in your Prezi editor: Select "Image": A toolbar will pop in from the right …
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question