A failed mkdir makes every following move overwrite the last file
Gemini CLI treated a failed directory creation as success, and on Windows each move then renamed files onto the same name.
- Agents
- Gemini CLI
- Reported
- Source checked
- Tags
- filesystem, windows, no-verification
Symptom
You ask the agent to reorganise a folder. It reports success, but the destination folder doesn't exist and the source folder is empty or holds a single file.
Cause
The directory-creation command failed, but the agent didn't check its result and kept going. On Windows, moving a file to a path that doesn't exist renames it, so each move overwrote the previous file.
Fix
Make the agent verify state after every write (read-after-write): check that the directory exists before moving anything into it, and stop on the first failed step. Work on a copy or a committed git tree so a bad reorganisation can be undone.
$dest = '..\new-folder'
New-Item -ItemType Directory -Path $dest -ErrorAction Stop | Out-Null
if (-not (Test-Path -PathType Container $dest)) { throw "missing $dest" }
Get-ChildItem -File | Move-Item -Destination $dest -ErrorAction Stop