LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-14-2016, 01:28 PM   #1
cilbuper
Member
 
Registered: Mar 2008
Posts: 141

Rep: Reputation: 0
Question Wget - how to rename files as they are download from range or input list


The files I need to get are as follows:

http://www.filehost.com/123444000/987
http://www.filehost.com/123423440/987
http://www.filehost.com/123443550/987
http://www.filehost.com/123444453/987
http://www.filehost.com/123442643/987

If I do a wget of any of these URL's I get the file saved in the correct format (whatever the file is, a PDF, JPG, etc - but they are all saved as "987.PDF" or "987.JPG"

I would like to rename the file anything else, preferably the preceding number before the /987

Is this possible with wget or will a script have to be written?
 
Old 07-14-2016, 02:23 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Feed into a loop, retrieve the desired name, use -O option of wget and rename as you see fit. You can of course do it one at a time and rename as you like.
 
Old 07-15-2016, 12:36 PM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
use the part of the url that changes to either rename the files, or download them into separate directories.
 
  


Reply

Tags
wget


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] rename as download wget sequentially bash ytd_usr Linux - Newbie 6 12-31-2015 01:02 PM
[SOLVED] rename files using text list carlosestensser Fuduntu 6 06-06-2012 12:33 PM
Rename files matching a list Qu3ry Programming 34 07-22-2009 06:59 PM
Print yum download list for wget a_m0d Fedora 6 05-09-2008 08:47 AM
awk cli to rename a list of files... pld Linux - General 4 02-15-2005 10:57 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration