Copy link to clipboard
Copied
Hello,
I am looking to start a disk cache cleanup script when closing After Effect.
The script is fully functional when I run it from the script executor.
However, when it is started at closing, I have the message displayed but nothing happens at the cache.
I think the problem is in the window that asks for confirmation before deletion (when it is started manually).
Do you have any ideas or solutions?
Here is the script (normally valid for CS6, CC) :
{
app.executeCommand(10200);
alert("Clear cache !");
}
Thank you in advance.
Have a good day.
Guillaume.
Hello,
Many thanks to justintaylor for his help.
I managed to do what I wanted as follows :
{
// After Effect - Cleaner Cache
// Get the path to the cache folder and convert \ in \\ ;
var CacheFilePath = app.preferences.getPrefAsString("Disk Cache Controls", "Folder 7")+"\\Adobe*";
var FullCacheFilePath = CacheFilePath.split('\\').join("\\\\");
// Delete my folder and these sub folders
system.callSystem('cmd.exe /c "for /d %a in ("'+Ful
...Copy link to clipboard
Copied
Moved to the After Effects Scripting forum.
Copy link to clipboard
Copied
It appears you can't clear disk cache via scripting. You can only clear the image/undo/snapshot caches:
http://docs.aenhancers.com/general/application/?highlight=disk%20cache#app-purge
As a workaround, you could write a script that manually deletes the caches in the cache directory.
On Mac it's: /Users/[username]/Library/Caches/Adobe/After Effects
or you can find it by going to Preferences > General > Media & Disk Cache > Choose Folder
Copy link to clipboard
Copied
Hello,
Thank you very much for your answer.
The function "app.executeCommand (10200)" is functional when executing the script manually.
In fact, it directly calls the "Clear cache" in preference. (See the list here for example: http://sydefxink.com/AECC2014_MenuIDs_v2_0.pdf)
What I do not explain is that the script does not work at 100% when activating via shutdown.
I have multiple users on the same machine and each user has their own cache. This saturates the machine. I need to find a way to purge the cache after the after effect closure or the user session.
If you have ideas I am listening.
Thank you.
Guillaume.
Copy link to clipboard
Copied
Yes, that command works with user input, selecting the OK button, but shutdown doesn't care about alerts and will just close them since it's shutting down After Effects. A lot of command IDs work this way, unfortunately. If there's not an API that does the same thing, then you have to get creative.
Only workaround that's coming to mind right now is looping through and deleting all the files in the system's cache folder with File.remove() / Folder.remove(), or executing a delete command via the system terminal per OS (rm -r on Mac or mrdir /s on PC) with system.callSystem().
NOTE: Be careful what you're deleting with this method, there is no undo option here.
Copy link to clipboard
Copied
Hello,
Thank you so much. It's clearer to me now.
In this case, I would like to successfully discover the filepath of the cache folder via the following command:
app.settings.getSetting ("Disk Cache Controls", "Folder 7")
This command does not seem to work and returns an error.
The script can not recover the section and the key.
Am I using the command correctly?
This value should be retrieved to be able to delete the cache via an ossystem regardless of the location setting.
Section of my preference file:
["Disk Cache Controls"]
"Enabled 2" = "0"
"Folder 7" = "C: \ Users \ AUTOMA ~ 1 \ AppData \ Local \ Temp"
"Max Size 3" = "22"
Thanks a lot for your help!
Guillaume
Copy link to clipboard
Copied
Use getPrefAsString() after defining the Pref File:
var pft = PREFType.PREF_Type_MACHINE_SPECIFIC;
app.preferences.getPrefAsString("Disk Cache Controls", "Folder 7", pft);
See here for more details: http://docs.aenhancers.com/other/settings/
Copy link to clipboard
Copied
Hello,
Many thanks to justintaylor for his help.
I managed to do what I wanted as follows :
{
// After Effect - Cleaner Cache
// Get the path to the cache folder and convert \ in \\ ;
var CacheFilePath = app.preferences.getPrefAsString("Disk Cache Controls", "Folder 7")+"\\Adobe*";
var FullCacheFilePath = CacheFilePath.split('\\').join("\\\\");
// Delete my folder and these sub folders
system.callSystem('cmd.exe /c "for /d %a in ("'+FullCacheFilePath+'") do rmdir "%a" /s /q"');
}
This script was placed in the "Shutdown Script" in order to be executed at the closing of after effect (and not the closing of a project).
Warning :
Script execution preferences must be enabled.
It may happen that the Directory is not deleted because some files are used: No worry, they will be deleted at the next closing.
I remain available for advice, improvement, question or others.
Copy link to clipboard
Copied
Hello Guillaume,
do you think your last script could work on cc2024? I tried it as a shutdown script but it does not work. I guess i am not understanding the ´´´ in the last line.. Is it " ´? Regards
Copy link to clipboard
Copied
Great script, but how to add Clear Memory (RAM) into this code chain?
// After Effect - Memory
app.executeCommand(10200);
Something like this?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more