π Kapothi Tech Adventure: The Space That Broke the Sync
The Mystery
OneDrive showed a scary error:
Bad Request (status code 400)β¦ The provided name cannot contain leading, or trailing, spaces.
The file looked fine, but hidden at the start was a sneaky space:
" Ada Vessantara Raja Putha - Various Artists.mp3"
The Fix
- Step 1: Spot the hidden space.
- Step 2: Rename the file to remove it.
- Step 3: Sync again β and it works!
The PowerShell Spell (for 100s of files)
# Go to the folder where your files are
cd "C:\SINHALA\OLD\Noorthi Gee Collection"
# Clean all filenames in this folder
Get-ChildItem -File | ForEach-Object {
$newName = $_.Name.Trim()
if ($newName -ne $_.Name) {
Rename-Item $_.FullName $newName
}
}
# If you want to include subfolders too:
Get-ChildItem -File -Recurse | ForEach-Object {
$newName = $_.Name.Trim()
if ($newName -ne $_.Name) {
Rename-Item $_.FullName $newName
}
}
The Lesson
Even invisible spaces can break big systems. Computers are precise, so every character matters.
Removing those ghost spaces turns errors into success β whether itβs one file or hundreds.