All ideasMore in Work

A batch file the AI wrote deleted 1,068 files in my project

The AI wrote a Windows batch helper as a UTF-8 file with LF line endings. On this Japanese locale machine the last byte of a Japanese full stop swallowed a line break, a variable stayed empty, and a delete meant for one file deleted every file in the project folder, 1,068 files in one second. 123 files could not be recovered.

This one went wrong. Read what happened so you don’t hit the same problem.

How it works

  1. Write tool creates a .cmd helper as UTF-8 with LF only line endings
  2. Cmd.exe reads it under codepage 932 and a line break is swallowed
  3. The set line for the work file never runs, so the variable stays empty
  4. Del /F /Q with an empty path deletes every file in the current folder
  5. 1,068 files deleted in one second, 123 unrecoverable

Why it’s worth knowing

A full stop at the end of a comment changed what the next line did. One empty variable turned a one file delete into deleting the whole folder.

Where it’s from

Summarized from a public post on github.com. See the original ↗

Upgraded prompt

A ready-to-use prompt for this idea, built from research on what makes AI agents do the job right: who the AI should be, the exact steps, and a check to make sure it was done the way you wanted.

1Who the AI should be
2The prompt, with the steps
3The check when it’s done
Upgraded prompts are coming soon.

Try next

Every idea is a real post from someone who tried it, summarized in our words, with a link to the original. App names are swapped for plain words.