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.
How it works
- Write tool creates a .cmd helper as UTF-8 with LF only line endings
- Cmd.exe reads it under codepage 932 and a line break is swallowed
- The set line for the work file never runs, so the variable stays empty
- Del /F /Q with an empty path deletes every file in the current folder
- 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 ↗