Skip to content

Instantly share code, notes, and snippets.

@waterada
Created December 18, 2015 02:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waterada/fcec0528888e398a0c6c to your computer and use it in GitHub Desktop.
Save waterada/fcec0528888e398a0c6c to your computer and use it in GitHub Desktop.
ファイル(写真等)を更新日付で振り分ける(PowerShell)
$TARGET_DIR = "C:\Users\usr160097.GMO\Documents\旧pc\写真\misumi2"
cd "${TARGET_DIR}"
$dirs = @{}
dir ./ | foreach {
$dir = $_.LastWriteTime.ToString("yyyyMMdd_")
$dir1 = $TARGET_DIR
$dir2 = $TARGET_DIR + "\" + $dir
$file = $_.Name
if ( $(test-path $dir2) -ne $True ) {
New-Item $dir2 -itemType Directory | Out-Null
}
Move-Item -force "${dir1}\${file}" "${dir2}\${file}"
#write "${dir2}\${file}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment