The external USB disk I use for PC backups (drive B, 1TB) had quietly filled up. Only about 4MB was left. Drive B holds Windows backups (system images and so on) and File History.
I noticed when a robocopy job that copies drive B to an internal HDD (drive G) stopped with “There is not enough space on the disk” (error 112). The hidden-folder problem I hit at the same time is in robocopy destination folder hidden: cause and fix.
Looking inside, File History took about 510GB, and about 444GB of that was Codex and Claude Code chat logs. The logs on the PC itself were only about 42GB in total, yet inside File History they had grown more than tenfold.
Short answer: chat logs grow every time you use the tool, and File History copies every changed file each hour and keeps it as a version. By default those versions are kept “Forever”, so a multi-gigabyte file gets copied in full every hour. I excluded .codex and .claude from File History and now copy only the latest version of the logs with robocopy.
What was using the space
Breakdown of File History on drive B (about 510GB):
| Folder | Size inside File History | Size on the PC (drive C) |
|---|---|---|
.codex\sessions (Codex chat logs) |
234GB | 15GB |
Rest of .codex |
83GB | 24GB |
.claude\projects (Claude Code chat logs) |
127GB | about 3.5GB (all of .claude) |
Both are hidden folders directly under the user folder (C:\Users\<User>), and on my PC both were included in File History.
The biggest item was a Codex chat log I started on September 13. On the PC it is a single 7.3GB file, but File History held 42 versions of it, 165GB in total. On November 4 alone, seven nearly identical 7.3GB versions were saved. The file with the most versions had 348.
And the versions in File History covered only about three weeks (October 15 to November 7). This wasn’t years of old versions piling up: my AI tool use had increased over the past few weeks, and the history ballooned all at once. The logs on the PC grew too: about 1GB in September, about 22GB in October, about 20GB in the first 8 days of November.
Cause: File History copies changed files every hour and keeps versions forever
Microsoft’s explanation of File History says:
- By default it checks for changes every hour and copies changed files to another location
- By default versions are kept forever. If the backup drive fills up, you can shorten how long they are kept
- If large files quickly use up the backup drive, you can exclude their folder
(Sources: Protecting user files with File History - Microsoft Learn, Windows 8: File History explained - Microsoft Learn)
A chat log is appended to on every exchange, so even one new line makes the file “changed”. Sure enough, every version inside File History was almost exactly 7.3GB: whole files, not differences. While you are using a 7GB log, File History can grow by up to 7GB an hour. My retention was still set to “Forever”, so nothing was ever removed.
Just shortening retention to, say, one month isn’t enough. A 7GB file saved a few times a day adds up to hundreds of GB in a month. So I took the chat logs out of File History.
Fix 1: exclude .codex and .claude from File History
- Open Control Panel → File History
- Click “Exclude folders” on the left, then “Add”
- Both are hidden folders, so type the path straight into the address bar of the folder picker and add it (replace
<user name>with yours)
C:\Users\<user name>\.codex C:\Users\<user name>\.claude
Excluding them doesn’t delete the chat logs on the PC. They just stop being saved to File History.
I also reviewed retention under “Advanced settings” on the left. I left “Save copies of files” at “Every hour (default)” and changed “Keep saved versions” from “Forever” to “1 year”. With the chat logs excluded, hourly saves barely add anything.
At the same time I moved the File History target from drive B to my NAS (“Select drive” → “Add network location”), then deleted the old B:\FileHistory, which freed about 510GB.
Fix 2: copy only the latest chat logs to the NAS with robocopy
Once excluded, the chat logs wouldn’t come back if I restored the PC. So I copy just “one latest version” of them to the NAS with robocopy. robocopy copies only changed files and overwrites them, so versions don’t pile up. The copy stays the same size as on the PC, about 42GB.
Here is the batch file I use (the NAS name is replaced with <NAS>). Feel free to use it.
@echo off set "dst=\\<NAS>\backup\chat-logs" set "logfolder=\\<NAS>\backup\backup-tools\chatlog-copy\log" set "logfile=%logfolder%\%date:~0,4%-%date:~5,2%-%date:~8,2%_chatlog.log" set "opts=/E /DCOPY:DAT /COPY:DAT /XJ /log+:"%logfile%" /np /R:2 /W:5" if not exist "%logfolder%\" mkdir "%logfolder%" if not exist "%logfolder%\" ( echo Cannot write to the NAS: %logfolder% pause exit /b 1 ) set "result=OK" if exist "%USERPROFILE%\.codex\" ( robocopy "%USERPROFILE%\.codex" "%dst%\.codex" %opts% if errorlevel 8 set "result=NG" ) if exist "%USERPROFILE%\.claude\" ( robocopy "%USERPROFILE%\.claude" "%dst%\.claude" %opts% if errorlevel 8 set "result=NG" ) rem Remove logs older than 93 days forfiles /P "%logfolder%" /M "*.log" /D -93 /C "cmd /c del @file" 2>nul if "%result%"=="NG" ( echo There were copy errors. Check the log: %logfile% pause exit /b 1 ) echo Done. Log: %logfile%
Key points:
- It uses
/E, not/MIR(mirror). If I delete a conversation on the PC, it stays on the NAS, as insurance against deleting one by mistake - Run it as your normal user (not as administrator). It then uses the same credentials as when you open the NAS in Explorer, so no password goes into the batch file
- It stops with an error when robocopy’s exit code is 8 or higher. Per robocopy - Microsoft Learn, 8 or higher means some files failed to copy (more in robocopy exit codes explained)
- The log file name uses
%date%and assumes a yyyy/mm/dd date format. With a different regional format, change those three parts
The first run copied 41.4GB with zero failures. The second copied only changed files (about 74MB) and finished in 28 seconds. When a multi-gigabyte log has been updated, though, that whole file is copied again and the run takes a few minutes.
Run it automatically with Task Scheduler
I don’t turn my PC on every day, so a fixed time alone would miss days. I run it on two triggers: “10 minutes after logon” and “daily at 12:00”. The 10-minute delay keeps it from running (and failing) before the NAS is reachable. If the PC was off at noon, it runs the next time the PC is on (-StartWhenAvailable).
Run this in PowerShell opened as administrator. Creating a logon-triggered task needs admin rights, but the task itself runs with normal user rights (-RunLevel Limited). Change the batch path to where you put it.
$a = New-ScheduledTaskAction -Execute 'D:\backup-scripts\copy-chatlogs-to-nas.bat' $t1 = New-ScheduledTaskTrigger -AtLogOn -User $env:USERNAME; $t1.Delay = 'PT10M' $t2 = New-ScheduledTaskTrigger -Daily -At 12:00 $p = New-ScheduledTaskPrincipal -UserId $env:USERNAME -LogonType Interactive -RunLevel Limited Register-ScheduledTask -TaskName 'Copy chat logs to NAS' -Action $a -Trigger $t1,$t2 -Principal $p -Settings (New-ScheduledTaskSettingsSet -StartWhenAvailable) -Force
If it ends by showing “Copy chat logs to NAS” and “Ready”, the task is registered. Each command is documented in Register-ScheduledTask - Microsoft Learn and New-ScheduledTaskSettingsSet - Microsoft Learn.
My script that backs up drive D to the NAS also runs daily from Task Scheduler: Back up a local folder to a password-protected NAS with Robocopy.
Later I also moved the chat log folders themselves from C to D (with a junction, so no app settings changed). Since they now live on D, they’re included in the daily D-to-NAS backup. Steps: Move Claude Code and Codex chat logs off drive C (in Japanese).
Summary
- File History copies changed files every hour by default and keeps versions forever
- Codex and Claude Code chat logs (
.codex,.claude) grow with every use, so multi-gigabyte files are saved in full every hour. On my PC, about 42GB of logs became about 444GB in File History - Exclude
.codexand.claudewith “Exclude folders” - Copy just the latest logs to a NAS with robocopy, scheduled with Task Scheduler
If you use AI coding tools daily and rely on File History, check how much free space its drive has left.


コメント