A number of people have mentioned to me that they didn't realize that Powershell is included by default in Windows 7. If you haven't yet jumped on the Powershell bandwagon, this is a good time. Powershell 2 includes a bunch of cool features like remoting (kind of like SSH) as well as a visual IDE for writing, editing and interactively debugging Powershell scripts.
许多人向我提到,他们没有意识到Windows 7中默认包含Powershell ,如果您还没有赶上Powershell潮流,那么现在是个好时机。 Powershell 2包括许多很酷的功能,例如远程处理(有点像SSH)以及用于编写,编辑和交互式调试Powershell脚本的可视IDE。
Powershell great for system administration, but I mostly use it for quick and dirty "portable" apps that I don't feel like writing C#/VB for. Plus, I'm using .NET anyway, so it's all the same.
Powershell非常适合系统管理,但是我主要将它用于我不想为其编写C#/ VB的快速而又肮脏的“便携式”应用程序。 另外,无论如何我都在使用.NET,所以都一样。
I wanted to download all my podcasts with Powershell, so I wrote this quick script in about 5 minutes. Other improvements I (or preferably you) could make to it could be: check the file size against the enclosure and re-download partials, rename the files to included a version of the title, include a progress bar.
我想使用Powershell下载所有播客,所以我在大约5分钟的时间内编写了此快速脚本。 我(或最好是您)可以做的其他改进可能是:对照附件检查文件大小,然后重新下载部分文件,将文件重命名为包括标题的版本,包括进度条。
Here's what I came up with. Perhaps you'll find it useful if you're not an iTunes/Zune person:
这是我想出的。 如果您不是iTunes / Zune用户,也许您会发现它很有用:
cd "C:\users\scottha\desktop\Hanselminutes Complete Download"
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
$a = ([xml](new-object net.webclient).downloadstring("http://feeds.feedburner.com/HanselminutesCompleteMP3"))
$a.rss.channel.item | foreach{
$url = New-Object System.Uri($_.enclosure.url)
$file = $url.Segments[-1]
$file
if (!(test-path $file))
{
(New-Object System.Net.WebClient).DownloadFile($url, $file)
}
}
Of course you'll want to change the first line and the RSS Feed URL as you like.
当然,您需要根据需要更改第一行和RSS Feed URL。
If you've never used Powershell before, note that it's locked down from running scripts be default. You'll need to run it as Administrator once and run
如果您以前从未使用过Powershell,请注意,默认情况下,它将无法运行脚本。 您需要以管理员身份运行一次并运行
Set-ExecutionPolicy unrestricted
This opens it up to run scripts, but it's not only VBS, the scripts won't run if you double-click them. You need to run powershell then type the name of your script to run it:
这将打开它来运行脚本,但不仅是VBS,如果双击它们,脚本将无法运行。 您需要运行powershell,然后键入脚本名称以运行它:
.\myscript.ps1
You can always set the execution policy back if it bothers you.
如果执行策略困扰您,您可以随时将其重新设置。
Hope this primitive mass podcast enclosure downloader is useful.
希望这个原始的大规模Podcast附件下载器有用。
翻译自: https://www.hanselman.com/blog/download-podcasts-with-powershell