Created
March 11, 2023 08:18
-
-
Save kirill-konshin/6c143b937c75d9c020fa64753ffd5ffa to your computer and use it in GitHub Desktop.
Automator script to evict a folder from iCloud (using JXA)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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