Skip to content

Instantly share code, notes, and snippets.

@risadams
Created May 20, 2023 16:27
Show Gist options
  • Save risadams/c6a020d8e02af7bb82b8cb3b095a44ec to your computer and use it in GitHub Desktop.
Save risadams/c6a020d8e02af7bb82b8cb3b095a44ec to your computer and use it in GitHub Desktop.
Sort all files into alphanumeric folders based on the first letter of the file name
$list = @()
65..90 | ForEach-Object {
$letter = [char]$_
New-Item -Path .\ -Name $letter -ItemType "directory"
move-item .\$letter`?* $letter
$list += $letter
}
$rest = get-childitem -path .\ -exclude $list
New-Item -Path .\ -Name "0-9" -ItemType "directory"
foreach ($f in $rest) {
move-item $f.fullname "0-9"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment