Monday, March 25, 2013
How about some code to get the new URLs that I've added to my favorites over the past 24 hours?
$NewFavorites = get-childitem $env:userprofile\favorites -recurse`
-include *.url |
where-object {($_.lastwritetime -ge (Get-date).adddays(-1))}
$urls = @()
Foreach ($NewFavorite in $NewFavorites) {
$content = get-content $NewFavorite
$url = ($content[1]).split("=")[1]
$urls += $url
}
$urls
I need to test more - what if I've added 0 or 1 item to my favorites, does this still work?
UPDATE:
And then again, this guy's a genius :)
Courtesy of http://madprops.org/blog/list-your-favorites-in-powershell/
And modified to get just the 'new' URLS
gci $env:userprofile\favorites -rec -inc *.url |
where-object {($_.lastwritetime -ge (Get-date).adddays(-1))}
| ? {select-string -inp $_ -quiet "^URL=http"}
| select @{Name="Name";`
Expression={[IO.Path]::GetFileNameWithoutExtension($_.FullName)}},`
@{Name="URL"; Expression={get-content $_ |`
? {$_ -match "^URL=http"} | % {$_.Substring(4)}}}
Hopefully my added line breaks still produce some code that runs.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment