Pages: 1
RSS
Scheduler, Is it possible?
 
Please:  

Is it possible to use the Scheduler to clear the "Clear Cache" in Preferences?  I'd like to be able to set it to delete when it reached a size limit or after so many days?

Thanks
 
No, that's not possible.

The image cache is only used if/when:

-You receive an HTML email
-AND this message uses (links to) images that are not included as attachments but are located on external servers
-AND you allow The Bat to download external images in general, or fr om this message's sender in particular
-AND the image has not been retrieved before

The Bat may well be automatically removing old entries, or entries that haven't been requested for a long time, or lim it the cache size to a certain size - that doesn't appear to be documented. But unless you are receiving HTML messages from an extraordinary number of different senders, the cache is unlikely to grow to an inconvenient size.
I volunteer as a moderator to help keep the forum tidy. I do not work for Ritlabs SRL.
 
I cannot agree with you, Daniel. Clearing cache is possible by external program launched by The Bat! as event in Scheduler. For this purpose the Windows PowerShell is ideally matched. First, you should create text file with name ClearCacheDir.ps1 and save it in location, say, <ScriptPath>. Here is the code for clearing files older than 7 days (you can change this as you wish):
Code
$now = Get-Date
$CacheDir = $env:email + "\imgfiles\"
dir $CacheDir | where {$_.LastWriteTime -le $now.AddDays(-7)} | del

Then you should create an event in The Bat! Scheduler with only one operation: run the PowerShell script. The command for this is following:

Code
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '<ScriptPath>\ClearCacheDir.ps1'"

Remember to use correct path "<ScriptPath>" in the command run by Scheduler.
Edited: Zygmunt Wereszczyński - 23 May 2022 00:59:36
 
Alright Zygmunt, but The Bat itself does not offer a solution of the type that David is looking for. Your hack may well work, but bluntly deleting the contents of the cache folder might -at least in theory- have unintended consequences, particularly if it's done whilst The Bat is running. If David still wants to implement it, I would recommend that he does not run it from The Bat, but instead creates a batch file that clears the cache folder and then launches The Bat -- and from then on, always use that batch file to launch The Bat. That would give him an empty cache everytime he uses The Bat (but frankly, I doubt if that would serve any meaningful purpose).
I volunteer as a moderator to help keep the forum tidy. I do not work for Ritlabs SRL.
 
Thanks Zygmunt and Daniel.  Zygmunt's solution is far to complicated for me.

I have a wonderful little program installed called Mindful and I'm able to set it to remind me every so many days to perform a task.  I'll set that to remind me to delete/view the size of the cache every 14 days or so.  For me a TB Schedule option it would be an advantage.

Thanks again
 
My experience is that TB! automatically deletes downloaded images after a while. How long is this "after a while", I don't know, nor do I see a way to control it. But it works for me. Note that I only manually download images for messages where I feel it is absolutely necessary, so my cache is never that big (right now it says 4 bytes  :D).
Pages: 1