Skip to content

Instantly share code, notes, and snippets.



Last active Jul 22, 2017
What would you like to do?
tidy download directory on windows
# tidy up the ~/Downloads directory
cd C:\Users\me\Downloads
$week_ago = (Get-Date).AddDays(-7)
dir | Select-Object {
$last_access = $_.lastAccessTime
if ($last_access -lt $week_ago) {
$path = "{0:yyyyMM}" -f $last_access
if (! (Test-Path $path)) { mkdir $path }
if ($_.FullName -notmatch "^20\d\d\d\d") { mv $_.FullName $path }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.