Skip to content

Instantly share code, notes, and snippets.

@OKsign
Created May 4, 2018 04:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save OKsign/a1f97ce991b2f08a04cac447af3f7478 to your computer and use it in GitHub Desktop.
Save OKsign/a1f97ce991b2f08a04cac447af3f7478 to your computer and use it in GitHub Desktop.
-- user input
set textFile to "" -- ex. "/Volumes/Data/A/file.txt"
set des1 to "" -- ex. "/Volumes/Data/A/folder"
-- end of user input
set textFilep to POSIX file textFile
set textFileRead to paragraphs of (read of textFilep)
set des1p to POSIX file des1
tell application "Finder"
open des1p
activate
delay 0.3
end tell
tell application "Finder"
set FName to get name of front window
end tell
set AppleScript's text item delimiters to {"/"}
set TarWin to last text item of des1
repeat 300 times
tell application "Finder"
activate
delay 0.2
if FName is TarWin then
exit repeat
end if
end tell
end repeat
tell application "System Events"
keystroke "a" using command down
delay 0.2
end tell
tell application "Finder"
set sel to get selection
try
repeat with i from 1 to count sel
reveal item i of sel
delay 0.02
set the clipboard to item i of textFileRead
delay 0.2
tell application "System Events"
key code 36
delay 0.3
keystroke "v" using command down
delay 0.3
key code 36
delay 1
end tell
end repeat
end try
tell application "System Events"
display notification "Done!" with title "Script 5"
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment