Skip to content

Instantly share code, notes, and snippets.

@ZSendokame
Last active March 22, 2026 21:23
Show Gist options
  • Select an option

  • Save ZSendokame/e60f089f5d9719fe9f55119e2fba3523 to your computer and use it in GitHub Desktop.

Select an option

Save ZSendokame/e60f089f5d9719fe9f55119e2fba3523 to your computer and use it in GitHub Desktop.
PowerShell oneliners
# Get all files in two depths with an m4v, change it to .mp4
Get-ChildItem */*.m4v | Rename-Item -NewName {$_.Name -Replace '\.m4v$', '.mp4'}
# Remove all mp4 / jpg files with integer-only names
Get-ChildItem -File */* | Where {$_.Name -Match "^[0-9]+\.(jpg|mp4)"} | Remove-Item
# Count all files in two depths
(Get-ChildItem */* | Measure-Object).Count
# Find all files in two depths created since the last day
(Get-ChildItem */*) | Where {$_.CreationTime -gt (Get-Date).AddDays(-1)}
# Find specific file in two depths
(Get-ChildItem */* | Where {$_.Name -eq "filename.jpg"}).FullName
# Generate sorted table for file count.
$folderTable = Get-ChildItem "folderpath" | ForEach-Object {
[PSCustomObject]@{
FolderName = $_.BaseName
FileCount = (Get-ChildItem $_ | Measure-Object).Count
}
} | Sort-Object -Property FileCount -Descending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment