Skip to content

Instantly share code, notes, and snippets.

View dcabines's full-sized avatar

David Cabiness dcabines

View GitHub Profile
@dcabines
dcabines / compress-folders.ps1
Created September 4, 2023 19:37
compress all folders inside current folder
foreach($folder in Get-ChildItem) {
if(Test-Path -PathType Leaf -Path "$folder.zip") {
Write-Host "Skipping $folder"
continue
}
Write-Host -NoNewline "Compressing $folder..."
Compress-7Zip -Path "$pwd\$folder" -ArchiveFileName "$folder.zip"
Write-Host "done"
}
@dcabines
dcabines / places.csv
Created December 4, 2023 23:31
ao: id,lng,lat
We can't make this file beautiful and searchable because it's too large.
51417,-123.25197,44.971416
55360,12.642866,42.546879
55585,-76.160188,39.982201
55536,-2.597938,51.450104
55165,28.942675,41.035439
51949,72.833672,18.94487
55445,-1.897225,52.474335
54432,-122.958577,38.504583
55606,-124.25909,40.587797
54815,12.395989,44.092597
Function Get-Files {
param ($path)
Get-ChildItem -Path $path -Recurse | ForEach-Object { @{ Name = $_.Name; Full = "$($_.Directory.FullName)\$($_.Name)"; } } | Sort-Object -Property {$_.Name.Replace('[','').Replace(']','').Replace('-','').Replace(' ','')}
}
$herePath = "H:\Path\To\Copy"
$therePath = $herePath -replace 'H:', 'T:'
$here = Get-Files($herePath)
$there = Get-Files($therePath)
$longestHere = $($here | ForEach-Object { $_.Name } | Measure-Object -Maximum -Property Length).Maximum + 5
foreach($file in Get-ChildItem -File) {
$folderName = $file.CreationTime.ToString('yyyy-MM-dd')
if (!(Test-Path -Path $folderName -PathType Container))
{
New-Item -Path $folderName -ItemType Directory
}
Move-Item -Path $file -Destination $folderName
}