Skip to content

Instantly share code, notes, and snippets.

@L422Y
Created July 20, 2018 00:13
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 L422Y/a2ef441f572186dc91e346a3575cffb3 to your computer and use it in GitHub Desktop.
Save L422Y/a2ef441f572186dc91e346a3575cffb3 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment