Monday, November 08, 2010 at 12:01 AM.
system.verbs.apps.FinderMenu.commands.findLockedFiles
local (confirmationdisabled = false);
local (ctmatches = 0); <<number of locked files we found
local (ctunlocked = 0); <<number of files we unlocked
local (usercancelled = false);
on unlockFolder (folder) {
msg (file.fileFromPath (folder));
rollBeachball ();
fileloop (f in folder) {
if file.isFolder (f) {
if not unlockFolder (f) { <<user cancelled
return (false)}}
else {
if file.isLocked (f) {
local (unlock = true);
if confirmationdisabled {
unlock = true}
else {
local (s, result);
s = "The file “" + file.fileFromPath (f) + "” is locked.";
s = s + " Would you like to unlock it?";
msg ("Option-yes disables confirmation dialog.");
result = dialog.yesNoCancel (s);
msg ("");
case result {
1 { <<yes
if kb.optionKey () {
confirmationdisabled = true};
unlock = true};
2 { <<no
unlock = false};
3 { <<cancel
usercancelled = true;
return (false)}}}; <<halt traversal
ctmatches++;
if unlock {
ctunlocked++;
file.unlock (f)}}}};
return (true)};
on visit (path) {
local (folder = path);
if not file.isFolder (path) {
folder = file.folderFromPath (path)};
return (unlockFolder (folder))};
FinderMenu.visitPaths (@visit);
msg ("");
if not usercancelled {
dialog.alert (ctmatches + " locked files found. " + ctunlocked + " were unlocked.")};
Finder.bringToFront ()
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.