Reputation: 19534
(First time with AppleScript...) I'm trying to bulk upload files from a local folder to a server via a single-upload form (legacy serverside software behind ddos wall, no control over it)
As I understand:
I'm having some trouble with syntax in implementing that...
(Also, if that's not the right/best approach, please provide a better one below!)
on run tell application "Finder" set mlist to (every file of folder "Macintosh HD:Users:username:filestouploadfolder") as alias list repeat with this_file in mlist tell application "Safari" activate do JavaScript "document.getElementById('selectToOpenFileDialog').click();" in document 1 choose file this_file end tell end repeat end tell return 0 end run
Upvotes: 0
Views: 336
Reputation: 19534
Hacked up a solution though it could probably be more elegant
on run tell application "Finder" set mfolder to "Macintosh HD:Users:yosun:png:" set myFiles to name of every file of folder mfolder end tell repeat with aFile in myFiles tell application "Safari" activate delay 1 do JavaScript "document.getElementById('addDeviceTargetUserView').click();" in document 1 delay 1 do JavaScript "document.getElementById('targetDimension').value=10;" in document 1 do JavaScript "document.getElementById('targetImgFile').click();" in document 1 end tell tell application "System Events" keystroke "G" using {command down, shift down} delay 1 keystroke "~/png/" & aFile as string delay 1 keystroke return delay 1 keystroke return delay 1 end tell tell application "Safari" activate delay 1 do JavaScript "document.getElementById('AddDeviceTargetBtn').click();" in document 1 end tell delay 10 end repeat end run
Upvotes: 0