Tool to delete InDesign and InCopy lock files
set dir to ""
on open dropped_dir
set dir to dropped_dir
end open
if length of dir is equal to 0 then
set dir to (choose folder with prompt "Choose a folder to scan for lock files")
end if
set list_of_files to {}
set file_info to {}
set thePath to text 1 thru -3 of (quoted form of POSIX path of dir) & "'"
set sc to "find " & thePath & " -type f -iname '*.idlk' -exec echo {} \\;"
set the_files to paragraphs of (do shell script sc)
repeat with nextLine in the_files
if length of nextLine is greater than 0 then
set sc to "cat " & (quoted form of POSIX path of nextLine) & " | strings"
set filename to text of (do shell script "basename " & quoted form of POSIX path of nextLine)
set info to paragraphs of (do shell script sc)
if length of info is greater than 0 then
set fileitem to filename & " – locked by " & item 1 of info & "
" & nextLine
copy fileitem to the end of list_of_files
end if
end if
end repeat
if length of list_of_files is greater than 0 then
set deleteFiles to choose from list list_of_files with prompt "Select the lock files to delete:" with multiple selections allowed
if length of deleteFiles is greater than 0 then
repeat with dFile in deleteFiles
set info to paragraphs of (dFile)
tell application "System Events" to delete alias (item 2 of info)
end repeat
display dialog "Deleted " & (length of deleteFiles) & " lock files."
else
display dialog "No files were selected. Aborting."
end if
else
display dialog "No lock files found."
end if
quit