Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have 2000 URLs in excel file. The URLs are in the first column and in the second column there are names for the files downloaded from URL in the first column. I can copy that and paste to .txt file if it's needed, no problem. File names contain spaces. I need to do this on Windows 7. Could you help me?

@Edit: Well, sorry If my problem is unclear. I'm not english native speaker. I have URL in first column and and I want to save the file downloaded from this URL with name from the second column. I want that spaces to be there. I want to download all the files with one command or batch file using "wget" tool.

share|improve this question
    
wget -i will read a list of URLs from a file, I'm not sure how you'd get it to rename the files as it download them, though. –  Rob Jan 31 '13 at 20:04
add comment

3 Answers

up vote 0 down vote accepted

Steps

  1. Open your worksheet in Excel and click File → Save As.

  2. Close Excel to unlock the file.

  3. Choose CSV (comma separated values) as type and same your file as urls.csv.

  4. Open a command prompt, execute

    type urls.csv
    

    and identify the value separator (character placed between URL and file name.

    If it's, e.g., a semicolon, execute the following command:

    for /f "delims=; tokens=1,2" %a in (urls.csv) do @wget -O "%b" "%a"
    

How it works

  • Excel saves the URLs and corresponding names as comma (or semicolon) separated values.

    Example:

    http://foo;bar
    http://foo bar;foobar
    
  • for /f ... %a (urls.csv) goes through all lines and saves the first value in %a and the second in %b.

    Here, delims=; specifies the semicolon as value separator and token=1,2 specifies that there will be two tokens.

  • wget -O "%b" "%a" saves %a in %b. Since the URL is quoted, Wget will automatically take care of spaces and other special characters.

  • The @ in front of @wget prevents the commands from being printed.

See also: For /f - Loop through text | SS64.com

share|improve this answer
    
Excel 2010 saves CSVs with commas for me. –  Karan Jan 31 '13 at 20:19
    
Excel 2003 seems to use semicolons. –  Dennis Jan 31 '13 at 20:21
    
Why call it "C"SV then and not SSV?! –  Karan Jan 31 '13 at 20:22
    
Slightly misleading, yes. Other applications use tabs. Semicolons are usually a better choice, since it's less likely that they will naturally occur in the cells. Now that I think of it, it's probably because my Office is in Spanish. We use the comma as a decimal separator, so actual CSVs would be a poor choice... –  Dennis Jan 31 '13 at 20:25
    
I don't think it's because of your Office language. Excel simply uses whatever character you've set as your OS' preferred List separator under Control Panel's Region and Language / Additional settings / Customize Format. –  Karan Jan 31 '13 at 20:27
show 2 more comments

Can we help you? Possibly, if you actually said what it is that you need to do. What do you mean 'file names"?

Here is a general answer. 1) In a spreadsheet program copy the column that contains the data from which you want to remove spaces. 2) Save that to a .txt file. 3) Open that .txt file in any program with working search and replace. 4) Search for spaces and replace with _ 5) Save that .txt file 6) Open it in your spreadsheet program. 7) You should have a column with data_data_data. 8) Copy that column into your original file.

Would that solve the puzzle?

share|improve this answer
    
Well, sorry If my problem is unclear. I'm not english native speaker. I have URL in first column and and I want to save the file downloaded from this URL with name from the second column. I want that spaces to be there. I want to download all the files with one command or batch file using "wget" tool. –  user194380 Jan 31 '13 at 19:53
add comment

Say Input.txt looks like this:

http://cdn.sstatic.net/superuser/img/sprites.png sp ri te.png
http://www.google.com/images/srpr/logo3w.png go og le.png

A single command like the following:

for /f "tokens=1*" %i in (Input.txt) do wget -O "%j" "%i"

will save the files as sp ri te.png and go og le.png respectively.

To use in a batch file, just double the % signs.

Note: Obviously, the URLs must not contain spaces. Ensure they are encoded to use %20 etc.

share|improve this answer
    
Here is the example of my URL, there is a redirection but wget has no problems with downloading. There are no spaces in the URLs. Will it work? dominiopublico.gov.br/pesquisa/… –  user194380 Jan 31 '13 at 20:11
    
I can (and did) try it, but would you care to try it yourself on some sample URLs and confirm? –  Karan Jan 31 '13 at 20:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.