Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Apple Computing Products:
macOS - Apps and Programs
Applescript to Copy from Clipboard to Terminal
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="kspin" data-source="post: 959479" data-attributes="member: 135139"><p>I need to figure out how to write a line in an applescript that will take what's on the clipboard (will be a file path) and paste it into the Terminal after the "cd" command. Then it will list out all of the files in that file path and save it as a txt file.</p><p></p><p>Right now, it looks a little something like this and I get the error is "Cant get keystroke "cd" of application "Terminal"</p><p></p><p>on open {dropped_item}</p><p> </p><p> tell application "Finder" to set the clipboard to the dropped_item as text</p><p> </p><p> tell application "Terminal" to keystroke "cd"</p><p> </p><p> tell application "System Events" to keystroke "v" using {command down}</p><p> </p><p> do shell script "ls */* | cat>>~/Desktop/filelist.txt"</p><p> </p><p>end open</p><p></p><p>OR If I use this script, I get this error: "AppleEvent handler failed"</p><p></p><p>on open {dropped_item}</p><p> </p><p> tell application "Finder" to set the clipboard to the dropped_item as text</p><p> </p><p> open application "Terminal"</p><p> </p><p> do shell script "cd" and pastefromclipboard</p><p> </p><p> do shell script "ls */* | cat>>~/Desktop/filelist.txt"</p><p> </p><p>end open</p><p></p><p>I also remember seeing something to the effect of "Can't make 'cd' into boolean" but I cannot find that version of my script at the moment.</p><p></p><p>Any help with this would be great. Thanks!</p></blockquote><p></p>
[QUOTE="kspin, post: 959479, member: 135139"] I need to figure out how to write a line in an applescript that will take what's on the clipboard (will be a file path) and paste it into the Terminal after the "cd" command. Then it will list out all of the files in that file path and save it as a txt file. Right now, it looks a little something like this and I get the error is "Cant get keystroke "cd" of application "Terminal" on open {dropped_item} tell application "Finder" to set the clipboard to the dropped_item as text tell application "Terminal" to keystroke "cd" tell application "System Events" to keystroke "v" using {command down} do shell script "ls */* | cat>>~/Desktop/filelist.txt" end open OR If I use this script, I get this error: "AppleEvent handler failed" on open {dropped_item} tell application "Finder" to set the clipboard to the dropped_item as text open application "Terminal" do shell script "cd" and pastefromclipboard do shell script "ls */* | cat>>~/Desktop/filelist.txt" end open I also remember seeing something to the effect of "Can't make 'cd' into boolean" but I cannot find that version of my script at the moment. Any help with this would be great. Thanks! [/QUOTE]
Verification
Name this item. 🍎
Post reply
Forums
Apple Computing Products:
macOS - Apps and Programs
Applescript to Copy from Clipboard to Terminal
Top