Skip to content

Instantly share code, notes, and snippets.

View zlovatt's full-sized avatar

Zack Lovatt zlovatt

View GitHub Profile
@zlovatt
zlovatt / ! paperless-ngx Post-Consumption Data Extraction from Filename Script.md
Last active April 15, 2024 20:13
paperless-ngx post-consumption script to extract details from filename

paperless-ngx Post-Consumption Data Extraction from Filename Script

This is a paperless-ngx post-consumption script to extract document data based on the original filename.

It was initially developed by @gulpman and posted in this discussion thread. I've made further changes, detailed below.

Parsing

The script assumes the following pattern: {Date} - {Correspondent} - {Title}, and can parse the following cases:

@zlovatt
zlovatt / hideGifsInSlidesBookmarklet.js
Last active June 28, 2022 23:32
Hide Gifs in Google Slides Sidebar Bookmarklet
javascript:(function(){var styleID="toggle-filmstrip-gifs";var style=document.getElementById(styleID);if(style){style.remove();return}var styleContent=document.createTextNode("#filmstrip%20svg%20:not(.sketchy-comment-indicator)%20>%20image%20{%20display:%20none%20!important;%20}");style=document.createElement("style");style.id=styleID;style.appendChild(styleContent);document.getElementsByTagName("head")[0].appendChild(style)})()
@zlovatt
zlovatt / getLayerType.jsx
Last active April 11, 2024 11:12
ExtendScript: Get AE Layer Type
(function getSelectedLayerType() {
/**
* Gets the type of a given layer
*
* @param {Layer} layer Layer to check
* @return {string} Layer type
*/
function getLayerType(layer) {
switch (layer.matchName) {
case "ADBE Vector Layer":
@zlovatt
zlovatt / copyToWinClipboard.jsx
Created July 6, 2021 16:53
Extendscript: Copy string to Windows clipboard
// Copy string from ESTK to Windows clipboard:
var myString = "Here is a string";
var cmdString = 'cmd.exe /c cmd.exe /c "echo ' + myString + ' | clip"';
system.callSystem(cmdString);
@zlovatt
zlovatt / getAudioItemkbps.jsx
Created July 6, 2021 16:52
Extendscript: get audio file bitrate
// This doesn't check that the selection is valid, or that it's an audio file.
// Based on: http://stackoverflow.com/questions/21634091/is-it-possible-to-get-bitrate-of-mp3
(function () {
var item = app.project.selection[0];
var duration = item.duration;
var fileSize = item.file.length;
var kbit = fileSize/128;
var kbps = Math.ceil(Math.round(kbit / duration) / 16) * 16;
@zlovatt
zlovatt / getSetTemplatePath.jsx
Last active July 6, 2021 16:52
Extendscript: Get & Set After Effects Template Path
function getTemplatePath () {
if (parseFloat(app.version) < 14.0) return;
try {
if (app.preferences.havePref("Template Project", "Location", PREFType.PREF_Type_MACHINE_INDEPENDENT)) {
return app.preferences.getPrefAsString("Template Project", "Location", PREFType.PREF_Type_MACHINE_INDEPENDENT);
} else {
throw new Error("Template Project Location preference does not exist.");
}
} catch(e) {
@zlovatt
zlovatt / getClipboardContents.jsx
Last active July 6, 2021 16:53
Extendscript: Get Clipboard Contents (Windows only)
// This will get the clipboard contents directly as a string
var clipboardContents = system.callSystem("cmd /c \"for /f \"eol=; tokens=* delims= \" %I in ('powershell Get-Clipboard') do @set CLIPBOARD_TEXT=%I && echo %I\"");
@zlovatt
zlovatt / getFocusedComp.jsx
Last active September 20, 2022 03:55
Extendscript: Gets currently open comp from timeline, as opposed to selected comp in project panel
(function () {
/**
* Gets currently open comp from timeline, as opposed to
* selected comp in project panel
*
* @returns {CompItem | null} Active comp, or null if none
*/
function getFocusedComp() {
var activeItem = app.project.activeItem;
@zlovatt
zlovatt / aeCameraData.jsx
Last active January 19, 2022 05:59
Extendscript: Get After Effects Camera Data
// Figuring out some math to determine aov, filmSize and focalLength in an AE camera, as these values aren't script-accessible.
// Assuming units are pixels, film size measuring horizontally
var comp = app.project.activeItem;
var camera = your camera layer;
var compSize = comp.width;
var cameraZoom = camera.zoom;
var depthOfField = camera.depthOfField;
var focusDistance = camera.focusDistance;
@zlovatt
zlovatt / getEnums.jsx
Last active January 8, 2023 00:04
Extendscript: AE enum values (17.7)
(function () {
var allEnums = {
AlphaMode: {},
AutoOrientType: {},
BlendingMode: {},
ChannelType: {},
CloseOptions: {},
FastPreviewType: {},
FeetFramesFilmType: {},
FieldSeparationType: {},