Occasionally, I need to download many files from a single site, where all of the files are numbered. For example, catching up on podcasts. To make this easier, I would usually create a html file, listing all of the files as links, and then use the Firefox extension "DownThemAll" to download those files.
If there are a lot of files, creating the html file can be time consuming. Below is a small powershell command line that will create a file with numbered files, formatted as HTML links. It can be easily modified to create any file with incrementing numerical output...
1..10 | foreach-object -begin {"<html>"} -process{"<a href=`"http://www.files.com/File" + ([string]$_).PadLeft(3,"0") + ".mp3`">File" + $_ + "</a>"} -end{"</html>"} | set-content c:\"download.html"
And here is the same command in a much more brief format.
1..10|% -b
{"<html>"} -p{"<a href=`"http://www.files.com/File"+([string]$_).PadLeft(3,"0")+".mp3`">File"+$_+"</a>"}
-en{"</html>"}|sc "c:\download.html"
This is what is written to the c:\download.html file after running this command:
<html>
<a href="http://www.files.com/File001.mp3">File1</a>
<a href="http://www.files.com/File002.mp3">File2</a>
<a href="http://www.files.com/File003.mp3">File3</a>
<a href="http://www.files.com/File004.mp3">File4</a>
<a href="http://www.files.com/File005.mp3">File5</a>
<a href="http://www.files.com/File006.mp3">File6</a>
<a href="http://www.files.com/File007.mp3">File7</a>
<a href="http://www.files.com/File008.mp3">File8</a>
<a href="http://www.files.com/File009.mp3">File9</a>
<a href="http://www.files.com/File010.mp3">File10</a>
</html>
Posted
Feb 22 2007, 11:04 AM
by
David