Skip to content

Instantly share code, notes, and snippets.

@kirill-konshin
Created March 11, 2023 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirill-konshin/6c143b937c75d9c020fa64753ffd5ffa to your computer and use it in GitHub Desktop.
Save kirill-konshin/6c143b937c75d9c020fa64753ffd5ffa to your computer and use it in GitHub Desktop.
Automator script to evict a folder from iCloud (using JXA)
const app = Application.currentApplication();
app.includeStandardAdditions = true;
function run(input, parameters) {
try {
if (input.length > 1) throw new Error('Has to be one folder');
let folder = input['0'].toString();
if (!folder) throw new Error('No folder');
const cmd = 'find ' + folder.replaceAll(' ', '\\ ') + ' -type f -exec brctl evict {} \\;';
const res = app.doShellScript(cmd)
.replaceAll(folder, '')
.replaceAll("'", '')
.replaceAll('evicted content of ', '');
app.displayDialog(cmd + '\n\n' + res);
} catch (e) {
app.displayDialog(e.message);
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment