Skip to content

Instantly share code, notes, and snippets.

View jonebarker's full-sized avatar

Jonathan jonebarker

  • New York
View GitHub Profile
@jonebarker
jonebarker / Powershell-Batch-File2Folder-Namesake-Move.ps1
Created February 27, 2026 17:35
[Powershell-Batch-File2Folder-Namesake-Move] Creates a folder for each file in PWD with respective name and places each file into respective folder. #powershell
Get-ChildItem -File | ForEach-Object
{
$name = [IO.Path]::GetFileNameWithoutExtension($_.Name)
$dest = Join-Path -Path $_.DirectoryName -ChildPath $name
New-Item -ItemType Directory -Path $dest -Force | Out-Null
Move-Item -Path $_.FullName -Destination $dest
}
@jonebarker
jonebarker / POSIX-Batch-File2Folder-Namesake-Move.sh
Last active February 27, 2026 17:36
[POSIX-Batch-File2Folder-Namesake-Move] Creates a folder for each file in PWD with respective name and places each file into respective folder.
for f in *; do
[ -f "$f" ] || continue
name="${f%.*}"
mkdir -p "$name"
mv "$f" "$name/"
done
@jonebarker
jonebarker / POSIX-Batch-File2Folder-Namesake.sh
Last active February 27, 2026 17:37
[POSIX-Batch-File2Folder-Namesake] Creates a folder for each file in PWD with respective name.
for f in *; do
[ -f "$f" ] || continue
name="${f%.*}"
mkdir -p "$name"
done