- Dec
- 265
- 4
While working with Gemini to write a script to force files to cloud-only, I noticed that Gemini wrote it in such a way that it skipped directories. I asked why. Gemini said directories occupy little space and should not be forced to be cloud-only. To be honest, I don't really know how OneDrive, iCloud, or Google Drive manages directories. For all I know, OneDrive may keep the directories local even if they are set to cloud-only; there is no advantage to them being cloud-only.
That aside, I asked Gemini to write a TCC script to set all directories to be pinned on my OneDrive. Here is the code Gemini generated.
==================
@echo off
setlocal
:: Define the root OneDrive folder
set "OneDriveRoot=D:\OneDrive"
:: Setup the log file in the script's current directory
set "LogFile=%_startpath%CacheOneDriveDir.log"
:: Initialize the log file
echo =================================================== > "%LogFile%"
echo CacheOneDriveDir Native Optimization Run: %_date %_time >> "%LogFile%"
echo Target Root: %OneDriveRoot% >> "%LogFile%"
echo =================================================== >> "%LogFile%"
echo. >> "%LogFile%"
iff not isdir "%OneDriveRoot%" then
echo [ERROR] OneDrive root folder not found at: %OneDriveRoot%
quit 1
endiff
echo Optimizing OneDrive directories...
echo Logging updates to: %LogFile%
:: 1. Force-Pin the Root Directory
:: (We do this silently as it's just a single fast operation)
attrib /q /D +P -U "%OneDriveRoot%"
:: ---------------------------------------------------------------------
:: 2. The Native Sweep (Zero Script-Level Looping)
:: ---------------------------------------------------------------------
:: TCC's ATTRIB command has native filtering (/A:...). It will internally
:: scan the disk, skip everything that doesn't match, apply the new
:: attributes, and output ONLY the paths it actually touched.
:: Sweep A: Find all subdirectories (/S /D) that are NOT Pinned (/A:D-P)
attrib /S /D /A:D-P +P -U "%OneDriveRoot%\*" >> "%LogFile%" 2>&1
:: Sweep B: Find all subdirectories (/S /D) that are stuck with the Unpinned flag (/A:DU)
attrib /S /D /A:DU +P -U "%OneDriveRoot%\*" >> "%LogFile%" 2>&1
:: Finalize the log entries
echo. >> "%LogFile%"
echo =================================================== >> "%LogFile%"
echo Optimization Completed: %_date %_time >> "%LogFile%"
echo =================================================== >> "%LogFile%"
echo.
echo [SUCCESS] Optimization complete. Check "%LogFile%" to view changed directories.
endlocal
quit
==================
Any thoughts on this?
Craig
That aside, I asked Gemini to write a TCC script to set all directories to be pinned on my OneDrive. Here is the code Gemini generated.
==================
@echo off
setlocal
:: Define the root OneDrive folder
set "OneDriveRoot=D:\OneDrive"
:: Setup the log file in the script's current directory
set "LogFile=%_startpath%CacheOneDriveDir.log"
:: Initialize the log file
echo =================================================== > "%LogFile%"
echo CacheOneDriveDir Native Optimization Run: %_date %_time >> "%LogFile%"
echo Target Root: %OneDriveRoot% >> "%LogFile%"
echo =================================================== >> "%LogFile%"
echo. >> "%LogFile%"
iff not isdir "%OneDriveRoot%" then
echo [ERROR] OneDrive root folder not found at: %OneDriveRoot%
quit 1
endiff
echo Optimizing OneDrive directories...
echo Logging updates to: %LogFile%
:: 1. Force-Pin the Root Directory
:: (We do this silently as it's just a single fast operation)
attrib /q /D +P -U "%OneDriveRoot%"
:: ---------------------------------------------------------------------
:: 2. The Native Sweep (Zero Script-Level Looping)
:: ---------------------------------------------------------------------
:: TCC's ATTRIB command has native filtering (/A:...). It will internally
:: scan the disk, skip everything that doesn't match, apply the new
:: attributes, and output ONLY the paths it actually touched.
:: Sweep A: Find all subdirectories (/S /D) that are NOT Pinned (/A:D-P)
attrib /S /D /A:D-P +P -U "%OneDriveRoot%\*" >> "%LogFile%" 2>&1
:: Sweep B: Find all subdirectories (/S /D) that are stuck with the Unpinned flag (/A:DU)
attrib /S /D /A:DU +P -U "%OneDriveRoot%\*" >> "%LogFile%" 2>&1
:: Finalize the log entries
echo. >> "%LogFile%"
echo =================================================== >> "%LogFile%"
echo Optimization Completed: %_date %_time >> "%LogFile%"
echo =================================================== >> "%LogFile%"
echo.
echo [SUCCESS] Optimization complete. Check "%LogFile%" to view changed directories.
endlocal
quit
==================
Any thoughts on this?
Craig
Last edited: