Finder Unlock Files

Here’s a quick little one I tossed together this afternoon to unlock any locked files in a specific folder:

set fileSample to choose folder with prompt "Choose a folder to process."
set folderName to name of (info for fileSample)
tell application "Finder" to set theFiles to files of folder fileSample

tell application "Finder"
	repeat with oneFile in theFiles
		set lockedStatus to locked of oneFile
		if locked of oneFile is true then
			set locked of oneFile to false
		end if
	end repeat
end tell


this does the same :wink:

tell application "Finder" to set locked of files of (choose folder with prompt "Choose a folder to process.") to false


I use this from AppleScript Editor (Scripts Menu) so I don’t have to switch to Finder.

tell application "AppleScript Editor"
	set fn to path of document 1 as Unicode text
	set mf to a reference to POSIX file fn as alias 
end tell
tell application "Finder"
		tell document file mf
			set {locked} to {true}
		end tell
	on error the error_message number the error_number
		tell application "AppleScript Editor" to display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1
	end try
	tell application "AppleScript Editor" to display dialog "Script: " & fn & " is Locked." with title "Lock Script " buttons {"OK"} default button 1 with icon 1 giving up after 2
end tell

I have installed FinderPop, so generally when in finder i just right click the file or selection. Fantastic!
But I need something for shortcut keys as well, -They are ready, must just find some great shortcuts, -I’ll make a toggle, - one shortcut key to remeber only. And remember to buy a pint for Turdy. :slight_smile:

A bit off context but this little snippet turns invisible files on and off I have it installed on a shortcut key.

-- Toggles invisble files in terminal.
set res to do shell script "/usr/bin/defaults read AppleShowAllFiles"
if res is "YES" then
	do shell script "/usr/bin/defaults write AppleShowAllFiles NO"
	do shell script "/usr/bin/defaults write AppleShowAllFiles YES"
end if
do shell script "killall Finder"

Best Regards