Background
Eyes set on Google news for a bit of distraction.
Adrian Kingsley-Hughes
Saw an article by Adrian Kingsley-Hughes :-
Titled :- These hidden cache files are bloating your Google Chrome
SubTitle :- Google Chrome could be storing a hundred thousand cached files on your computer, and it doesn’t give you a way to delete them.
Link :- Link
Timeline
- Google Chrome, The Storage Hoarder
- Date Published :- 2019-April-25th
Link
- Date Published :- 2019-April-25th
Explore
Let us look at one of our machines and see what it looks like.
OS – MS Windows
Folder
On MS Windows, Google’s Chrome User Data is saved here :-
- User Data
- Pattern
- C:\Users\<username>\AppData\Local\Google\Chrome\User Data
- Sample
- C:\Users\dadeniji\AppData\Local\Google\Chrome\User Data
- Pattern
- Code Cache – JavaScript
- Pattern
- C:\Users\<username>\AppData\Local\Google\Chrome\User Data\Default\Code Cache\js
- Sample
- C:\Users\dadeniji\AppData\Local\Google\Chrome\User Data\Default\Code Cache\js
- Pattern
Explorer
File Listing
Image
Explanation
- Number of Files :- 110,613 items
- Files
- File Names
- Data Files
- *_0
- Index Files
- index
- Index-dir
- File Folder
- Data Files
- File Names
Files – Storage Used
Image
Explanation
- Size :- 35.1 MB
- Size on disk :- 47.3 MB
- Number of Files :- 21,655 Files
Code
Outline
- Identify Google Chrome JavaScript Code Cache Folder
- OS Environment Variable
- APPDATA
- C:\Users\dadeniji\AppData\Roaming
- LOCALAPPDATA
- C:\Users\dadeniji\AppData\Local
- APPDATA
- OS Environment Variable
- Get Total In Use Files Size
- Issue dir
- Parse output of dir command
- Look for the word bytes
- Then parse for Files
- Parse output of dir command
- Issue dir
- If parameter cleanup passed in, please remove files
- Command – forfiles
- parameters
- /p
- <folder>
- /m
- *_0
- /C
- cmd /C dir /b @path & del @path
- dir /b @path
- list file name
- del @path
- delete file
- &
- concatenate command
- dir /b @path
- cmd /C dir /b @path & del @path
- /p
- parameters
- Command – forfiles
Script
Here is a script cleaning things up on MS Windows
@echo off setlocal set "_appData=%APPDATA%" set "_appDataLocal=%LOCALAPPDATA%" set "_googleChromeCodeCacheJS=%_appDataLocal%\Google\Chrome\User Data\Default\Code Cache\js" dir "%_googleChromeCodeCacheJS%" | findstr "bytes" | findstr "File" IF [%1]==[] ECHO Please pass in cleanup to actually cleanup if "%1" == "cleanup" ( if exist "%_googleChromeCodeCacheJS%"\*_0 ( echo cleaning up ... forfiles /p "%_googleChromeCodeCacheJS%" /M "*_0" /C "cmd /C dir /b @path & del @path " echo cleaned up ) ) :complete endlocal
Output
Output
Source Code
Github
Gist
DanielAdeniji/pruneGoogleCacheJavaScript.cmd
Link