最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Set downloaded filename in a different directory using wget - Stack Overflow

programmeradmin1浏览0评论

I need to download a zip file using wget. To download it in current directory I run in mand line:

 $ wget /.../[myfile].zip

To download it in a different different directory I add -P <Path of download directory>:

$ wget -P [download directory path] /.../[myFile].zip

I want to change to download the file into [download path directory] but with filename [myFileName]. How can I do this?

I've already tried this:

$ wget -P [download directory path] --output-document=[filename.zip] 
/.../[myZipFile].zip

This downloads the file into current directory with filename chose by me.

Finnaly I will use this into a NodeJS project using spawn.

Currently I have this:

var downloader = spawn("wget", ["-P", zipFile, appUrl]);

I need to download a zip file using wget. To download it in current directory I run in mand line:

 $ wget https://github./.../[myfile].zip

To download it in a different different directory I add -P <Path of download directory>:

$ wget -P [download directory path] https://github./.../[myFile].zip

I want to change to download the file into [download path directory] but with filename [myFileName]. How can I do this?

I've already tried this:

$ wget -P [download directory path] --output-document=[filename.zip] 
https://github./.../[myZipFile].zip

This downloads the file into current directory with filename chose by me.

Finnaly I will use this into a NodeJS project using spawn.

Currently I have this:

var downloader = spawn("wget", ["-P", zipFile, appUrl]);
Share Improve this question edited Mar 5, 2013 at 16:42 jcubic 66.7k58 gold badges249 silver badges453 bronze badges asked Mar 5, 2013 at 16:38 Ionică BizăuIonică Bizău 113k93 gold badges307 silver badges487 bronze badges 5
  • 2 Why don't you download it from node.js ? – Floby Commented Mar 5, 2013 at 16:41
  • What you mean? The zip file is on Github. – Ionică Bizău Commented Mar 5, 2013 at 16:42
  • 2 I mean nodejs/api/http.html or github./mikeal/request – Floby Commented Mar 5, 2013 at 16:46
  • Where did you get these indications from? – Floby Commented Mar 5, 2013 at 16:50
  • 2 wget is an almost-always installed tool, probably for this reason it's in whatever indications you're referring to. Using wget from node.js to download a file; is pretty weird. – AD7six Commented Mar 5, 2013 at 17:07
Add a ment  | 

1 Answer 1

Reset to default 8

Maybe I'm missing the point of the Q, but what about the -O flag?

wget -O [download directory path]/[filename.zip] https://github./.../[myZipFile].zip

The man page has scary stuff about files concatenated, but that won't matter when you are only fetching one file.

To auto-create the directory first:

mkdir -p [download directory path]; wget -O [download directory path]/[filename.zip] https://github./.../[myZipFile].zip

the -p (parents) flag on mkdir causes it to exit without an error if the directory already exists.

发布评论

评论列表(0)

  1. 暂无评论