Last active
July 22, 2017 22:05
-
-
Save kiyoto/09ecc0dc66333fe1acf7bdd9146c75e0 to your computer and use it in GitHub Desktop.
tidy download directory on windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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