Windows7 コマンドプロンプトでファイルを一括ダウンロードする

bitsadminというコマンドを使う。HTTPとHTTPSをサポートしている。
(コマンドの説明に、いつまでサポートされるか分からないみたいなことが書いてある。)

ダウンロードする場合。

構文:bitsadmin /TRANSFER ジョブ名(任意) ダウンロードURL1 保存ファイル名1 ダウンロードURL2 保存ファイル名2 ダウンロードURL3 保存ファイル名3 ……
※保存ファイル名はフルパス指定。%CD%でカレントディレクトリ指定。なおディレクトリは既存のもの。

例:bitsadmin /TRANSFER getfiles http://…1.pdf C:\…\PDF1.pdf http://…2.jpg C:\…\JPG1.jpg http://…3.pdf %CD%PDF2.pdf
※一つのジョブで複数ファイルを指定した方が、ダウンロードが順序よく行われるので都合がいいようだ。

手順

  1. ウェブページのHTMLソースなどからダウンロードリストを作る
  2. 保存ファイル名に禁則文字が入らないようにチェックする
  3. 保存フォルダでの一覧表示順序を考えて番号付けなどをする
  4. バッチファイルに保存して、コマンドプロンプトから実行する
参考:bitsadminコマンドの説明文
BITSADMIN version 3.0 [ 7.5.7601 ]
BITS administration utility.
(C) Copyright 2000-2006 Microsoft Corp.

BITSAdmin is deprecated and is not guaranteed to be available in future versions of Windows.
Administrative tools for the BITS service are now provided by BITS PowerShell cmdlets.

USAGE: BITSADMIN [/RAWRETURN] [/WRAP | /NOWRAP] command
The following commands are available:

/HELP           Prints this help 
/?              Prints this help 
/UTIL /?        Prints the list of utilities commands 
/PEERCACHING /?   Prints the list of commands to manage Peercaching
/CACHE /?       Prints the list of cache management commands 
/PEERS /?       Prints the list of peer management commands

/LIST    [/ALLUSERS] [/VERBOSE]     List the jobs
/MONITOR [/ALLUSERS] [/REFRESH sec] Monitors the copy manager
/RESET   [/ALLUSERS]                Deletes all jobs in the manager

/TRANSFER  [type] [/PRIORITY priority] [/ACLFLAGS flags] 
          remote_url local_name
    Transfers one of more files.
    [type] may be /DOWNLOAD or /UPLOAD; default is download
    Multiple URL/file pairs may be specified.
    Unlike most commands,  may only be a name and not a GUID.

/CREATE [type]                Creates a job
    [type] may be /DOWNLOAD, /UPLOAD, or /UPLOAD-REPLY; default is download
    Unlike most commands,  may only be a name and not a GUID.

/INFO  [/VERBOSE]                   Displays information about the job
/ADDFILE    Adds a file to the job
/ADDFILESET               Adds multiple files to the job
   Each line of  lists a file's remote name and local name, separated
   by spaces.  A line beginning with '#' is treated as a comment.
   Once the file set is read into memory, the contents are added to the job.

/ADDFILEWITHRANGES    
   Like /ADDFILE, but BITS will read only selected byte ranges of the URL.
   range_list is a comma-delimited series of offset and length pairs.
   For example,

       0:100,2000:100,5000:eof

   instructs BITS to read 100 bytes starting at offset zero, 100 bytes starting
   at offset 2000, and the remainder of the URL starting at offset 5000.

/REPLACEREMOTEPREFIX   
    All files whose URL begins with  are changed to use 

Note that BITS currently supports HTTP/HTTPS downloads and uploads.
It also supports UNC paths and file:// paths as URLS

/LISTFILES                      Lists the files in the job
/SUSPEND                        Suspends the job
/RESUME                         Resumes the job
/CANCEL                         Cancels the job
/COMPLETE                       Completes the job

/GETTYPE                        Retrieves the job type
/GETACLFLAGS                    Retrieves the ACL propagation flags

/SETACLFLAGS         Sets the ACL propagation flags for the job
  O - OWNER       G - GROUP 
  D - DACL        S - SACL  

  Examples:
      bitsadmin /setaclflags MyJob OGDS
      bitsadmin /setaclflags MyJob OGD

/GETBYTESTOTAL                  Retrieves the size of the job
/GETBYTESTRANSFERRED            Retrieves the number of bytes transferred
/GETFILESTOTAL                  Retrieves the number of files in the job
/GETFILESTRANSFERRED            Retrieves the number of files transferred
/GETCREATIONTIME                Retrieves the job creation time
/GETMODIFICATIONTIME            Retrieves the job modification time
/GETCOMPLETIONTIME              Retrieves the job completion time
/GETSTATE                       Retrieves the job state
/GETERROR                       Retrieves detailed error information
/GETOWNER                       Retrieves the job owner
/GETDISPLAYNAME                 Retrieves the job display name
/SETDISPLAYNAME   Sets the job display name
/GETDESCRIPTION                 Retrieves the job description
/SETDESCRIPTION    Sets the job description
/GETPRIORITY                    Retrieves the job priority
/SETPRIORITY          Sets the job priority
   Priority usage choices:
      FOREGROUND 
      HIGH
      NORMAL
      LOW
/GETNOTIFYFLAGS                  Retrieves the notify flags
/SETNOTIFYFLAGS    Sets the notify flags
    For more help on this option, please refer to the MSDN help page for SetNotifyFlags/GETNOTIFYINTERFACE              Determines if notify interface is registered
/GETMINRETRYDELAY                Retrieves the retry delay in seconds
/SETMINRETRYDELAY   Sets the retry delay in seconds
/GETNOPROGRESSTIMEOUT            Retrieves the no progress timeout in seconds
/SETNOPROGRESSTIMEOUT   Sets the no progress timeout in seconds
/GETMAXDOWNLOADTIME              Retrieves the download timeout in seconds
/SETMAXDOWNLOADTIME     Sets the download timeout in seconds
/GETERRORCOUNT                   Retrieves an error count for the job

/SETPROXYSETTINGS        Sets the proxy usage
   usage choices:
    PRECONFIG   - Use the owner's default Internet settings.
    AUTODETECT  - Force autodetection of proxy.
    NO_PROXY    - Do not use a proxy server.
    OVERRIDE    - Use an explicit proxy list and bypass list. 
                  Must be followed by a proxy list and a proxy bypass list.
                  NULL or "" may be used for an empty proxy bypass list.
  Examples:
      bitsadmin /setproxysettings MyJob PRECONFIG
      bitsadmin /setproxysettings MyJob AUTODETECT
      bitsadmin /setproxysettings MyJob NO_PROXY
      bitsadmin /setproxysettings MyJob OVERRIDE proxy1:80 "" 
      bitsadmin /setproxysettings MyJob OVERRIDE proxy1,proxy2,proxy3 NULL 

/GETPROXYUSAGE                  Retrieves the proxy usage setting
/GETPROXYLIST                   Retrieves the proxy list
/GETPROXYBYPASSLIST             Retrieves the proxy bypass list

/TAKEOWNERSHIP                  Take ownership of the job

/SETNOTIFYCMDLINE   [program_parameters] 
    Sets a program to execute for notification, and optionally parameters.
    The program name and parameters can be NULL.
    IMPORTANT: if parameters are non-NULL, then the program name should be the
               first parameter.

  Examples:
    bitsadmin /SetNotifyCmdLine MyJob c:\winnt\system32\notepad.exe  NULL
    bitsadmin /SetNotifyCmdLine MyJob c:\foo.exe "c:\foo.exe parm1 parm2" 
    bitsadmin /SetNotifyCmdLine MyJob NULL NULL

/GETNOTIFYCMDLINE               Returns the job's notification command line

/SETCREDENTIALS     
  Adds credentials to a job.
   may be either SERVER or PROXY
   may be BASIC, DIGEST, NTLM, NEGOTIATE, or PASSPORT. 

/REMOVECREDENTIALS    
  Removes credentials from a job.
/GETCUSTOMHEADERS                            Gets the Custom HTTP Headers
/SETCUSTOMHEADERS    <...> Sets the Custom HTTP Headers
/GETCLIENTCERTIFICATE                        Gets the job's Client Certificate Information
/SETCLIENTCERTIFICATEBYID    
  Sets a client authentication certificate to a job.
   may be 
        1(CURRENT_USER), 2(LOCAL_MACHINE), 3(CURRENT_SERVICE),
        4(SERVICES), 5(USERS), 6(CURRENT_USER_GROUP_POLICY),
        7(LOCAL_MACHINE_GROUP_POLICY) or 8(LOCAL_MACHINE_ENTERPRISE). 

/SETCLIENTCERTIFICATEBYNAME    
  Sets a client authentication certificate to a job.
   may be 
        1(CURRENT_USER), 2(LOCAL_MACHINE), 3(CURRENT_SERVICE),
        4(SERVICES), 5(USERS), 6(CURRENT_USER_GROUP_POLICY),
        7(LOCAL_MACHINE_GROUP_POLICY) or 8(LOCAL_MACHINE_ENTERPRISE). 

/REMOVECLIENTCERTIFICATE                 Removes the Client Certificate Information from the job

/SETSECURITYFLAGS     
   Sets the HTTP security flags for URL redirection and checks performed on the server certificate during the transfer.
   The value is an unsigned integer with the following interpretation for the bits in the binary representation.
     Enable CRL Check                                 : Set the least significant bit
     Ignore invalid common name in server certificate : Set the 2nd bit from right
     Ignore invalid date in  server certificate       : Set the 3rd bit from right
     Ignore invalid certificate authority in server
       certificate                                    : Set the 4th bit from right
     Ignore invalid usage of certificate              : Set the 5th bit from right
     Redirection policy                               : Controlled by the 9th-11th bits from right
         0,0,0  - Redirects will be automatically allowed.
         0,0,1  - Remote name in the IBackgroundCopyFile interface will be updated if a redirect occurs.
         0,1,0  - BITS will fail the job if a redirect occurs.

     Allow redirection from HTTPS to HTTP             : Set the 12th bit from right

/GETSECURITYFLAGS    
   Reports the HTTP security flags for URL redirection and checks performed on the server certificate during the transfer.

/SETVALIDATIONSTATE     
       starts from 0          
    Sets the content-validation state of the given file within the job.

/GETVALIDATIONSTATE      
       starts from 0          
    Reports the content-validation state of the given file within the job.

/GETTEMPORARYNAME      
       starts from 0          
    Reports the temporary filename of the given file within the job.

The following options control peercaching of a particular job:

/SETPEERCACHINGFLAGS      
    Sets the flags for the job's peercaching behavior.
    The value is an unsigned integer with the following interpretation for the bits in the binary representation.
        Allow the job's data to be downloaded from a peer : Set the least significant bit
        Allow the job's data to be served to peers        : Set the 2nd bit from right

/GETPEERCACHINGFLAGS                 
    Reports the flags for the job's peercaching behavior.

The following options are valid for UPLOAD-REPLY jobs only:

/GETREPLYFILENAME         Gets the path of the file containing the server reply
/SETREPLYFILENAME   Sets the path of the file containing the server reply
/GETREPLYPROGRESS         Gets the size and progress of the server reply
/GETREPLYDATA             Dumps the server's reply data in hex format

The following options can be placed before the command:
/RAWRETURN                     Return data more suitable for parsing
/WRAP                          Wrap output around console (default)
/NOWRAP                        Don't wrap output around console

The /RAWRETURN option strips new line characters and formatting.
It is recognized by the /CREATE and /GET* commands.

Commands that take a  parameter will accept either a job name or a job ID
GUID inside braces.  BITSADMIN reports an error if a name is ambiguous.