applescript , Applescript Copy All File from USB to Folder


Applescript Copy All File from USB to Folder

Question:

Tag: applescript

Could you help me to make this script working ?

property ignoredVolumes : {"DD APPLE", "MobileBackups"} 
tell application "System Events"

set Destination_Folder to folder "/Users/Joseph/Downloads/Test" of startup disk
set rootVolume to disk item (POSIX file "/Volumes" as text)
set allVolumes to name of every disk item of rootVolume

repeat with aVolume in allVolumes
    if aVolume is not in ignoredVolumes then
        copy every item of folder (aVolume) to Destination_Folder
    end if
end repeat
end tell

The problem is in the line copy every item of folder (aVolume) to Destination_Folder - the error message I get is Can’t get every file of "NO NAME". (No Name is my USB key.)

Thank you very much for your help.


Answer:

System Events doesn't have a "copy" command. Where did you get that? You might try "move" instead. Plus "aVolume" is not a folder, it's a disk. You probably want to change "folder aVolume" to "disk aVolume". And you might even need to use "disk (contents of aVolume)"

EDIT: Try the following script. I didn't test it but it should work. Good luck.

property ignoredVolumes : {"DD APPLE", "MobileBackups", "home", "net"} -- leave home and net in this list
set Destination_Folder to ((path to downloads folder as text) & "Test:") as alias

set mountedVolumes to list disks

repeat with i from 1 to count of mountedVolumes
    set thisVolume to item i of mountedVolumes
    if thisVolume is not in ignoredVolumes then
        tell application "Finder"
            set theItems to items of disk thisVolume
            move theItems to Destination_Folder
        end tell
    end if
end repeat

Related:


how do you find the square root of a number in applescript


applescript,calculator,square-root
I have a simple calculator code and I want to include square root in it. I am relatively new to applescript and I have no idea how. It might be nooby but thanks anyway!

Multiple if conditions within nested repeat while in applescript


applescript
I've never used AppleScript before, so i'm quite unfamiliar with the language, but i'm doing my best. Here's what i'm trying to accomplish: Run a script while selecting a folder filled with .ARW and .JPG files. Iterate through the items in the folder. If the current item is .ARW, iterate...

AppleScript (or swift) add hours to time


swift,date,applescript
I'm trying to add 8Hours to a date (from the clipboard) set date1 to the clipboard set newdate to date1 + (8 * hours) display dialog "Purchases were downloaded at " & newdate buttons {"OK"} default button 1 But this is not working as expected, I'm having the error Can’t...

Applescript Error -1700, cant make ~/Desktop/ into an alias


osx,applescript
set source to (choose folder default location ("~/Desktop/") with multiple selections allowed) repeat with filetocopy in source set n to (quoted form of (POSIX path of filetocopy)) & " " set dir to do shell script "dirname " & n set bn to do shell script "basename " & n...

Applescript Automator default text field value


xcode,applescript,automator
i'm trying to make an automator action to rename files to my specific needs. that's 3 text field, one for the date in YYYYMMDD format, one of the project I'm working on and one for the filename itself. so i've figured everything out so far except this specific question/task. is...

Try statements acting up in AppleScript


applescript
I'm trying to figure out try statements in AppleScript. I got it to compile, but it doesn't do what I want it to do. try do shell script "cat " & passData on error display dialog "Create a password to protect this file. After creating the password, you will need...

AppleSctipt Finding File with partial filename


get,applescript,filenames
I am an applescript noob and i need help getting a certain log file that has a long string of numbers in its title. The number changes and the filename before the number string is unique to the folder it is in. Is there some way i can use the...

How to copy a file from a selected message to an outgoing message in outlook through applescript?


outlook,applescript
I have been trying to figure out how to copy an attachment from an incoming message in outlook to a new outgoing message through applescript. The code below is what I've got so far, but it's definitely wrong. Outlook throws and error at me stating: "Microsoft Outlook got an error:...

applescript how to remove “\”s from my text in a variable


applescript
Okay so I have a code that grabs text from Wolfram alpha after I ask a question and create the URL and stores it in the variable "answer" but it has / symbols mixed in with the text and the system pronounces words wrong because of it. How can I...

make bash script display system event dialog, then take its result and use it in an if statement


osx,bash,shell,applescript
This is my first time posting on StackOverflow after lurking for long time. I am running Mac OS X 10.10.3. I am a bash novice. I have a script that, after asking for confirmation using read in Terminal, uses grep to check whether /dev/disk1 is mounted, then formats that disk....

Getting directory of input file (Applescript)


applescript
I'm confused - I've been googling for an hour and have tried probably ten different forms of set posixDirectory to POSIX path of (parent of (path to aFile) as string) but I can't seem to get it right. I'm getting the full POSIX path (including the filename) by doing set...

Save/convert .applescript as .scpt


applescript
Is there a way to convert .applescript files to compiled .scpt files? I am currently using AppleScript-Sublime-Text to edit my AppleScripts in Sublime Text, and to run them (using Cmd-B). But I was wondering, is there a way to also save the files to a .scpt file from within Sublime...

Make AppleScript Case-Sensitive


applescript,case-sensitive
In the following script, set theText to "ASDF" set lowercase to "abcdefghijklmnopqrstuvwxyz" set numeric to "0123456789" set containsLowercase to false set containsUppercase to false set containsNumber to false set containsSomethingElse to false repeat with theCharacter in theText if lowercase contains theCharacter then set containsLowercase to true else if uppercase contains...

use statement not working in AppleScript


applescript,use
I am creating my first AppleScript library in a script file, and would like to use the handlers in that file using the use statement (I followed these instructions). So I tried: use script "My Library" create_new_track(10, 2, 2) Inside my "My Library.scpt" file, there is a handler called "create_new_track"....

AppleScript check for string value in input


applescript
new to applescript and this small check is driving me nuts. I want to check if the input to the script has the substring of "mob". If i create a varible with mob1234, It works and returns true. on run {input, parameters} set testString to "mob1234" display dialog {"MOB" is...

Applescript Read File line by line


applescript
I'd like to make an applescript that reads a text file and for each line copies the text to the clipboard (what it does with it from here I have sorted) before moving onto the next line and copying that to the clipboard. Thanks!

Using AppleScript, how to set the value of a cell of the Numbers App/iWork file


applescript,automator,iwork
Using the numbers file below, how do i set a value into cell B2? The hard part is that i cannot use any of the code below: set the value of cell 2 of column "B" to "200.00" or set the value of cell "B2" to "200.00" Based on the...

AppleScript “on open” misbehavior


applescript
I have a list of jpeg images on a local server that I use an AppleScript droplet to resize in Photoshop. I use "on open" to do this, but something strange happens: they open in two parts. The files are named as follows: 0_203.jpg 1_203.jpg 2_203.jpg 3_203.jpg 4_203.jpg 5_203.jpg 6_203.jpg...

applescript Calculator not working


applescript,calculator
I have made a calculator which should work but doesn't. The only part that works is the addition. this is my code: my Calculator() on Calculator() display dialog "Calculator" buttons {"Add", "Multiply", "Divide"} if button returned of the result is "Add" then display dialog "What plus What?" default answer ""...

Python: Reading characters in ASCII and giving an output with clicks


python,osx,applescript
I'm fairly new to python so sorry if this is either very basic or alternatively something that is completely impossible to do. What I'm trying to do is create a script that will read characters then output left or right clicks in ASCII binary according to the character read. Left...

Check for charset size with AppleScript


security,passwords,applescript
I'm trying to make a script that based on charset size and guesses per second, makes an estimate on how long it would take to crack a password that the user inputs in a box. So far I can only get it to check for numbers, by trying to add...

Characters x through y in Applescript


applescript
I'm writing an AppleScript that generates a random number which is then inserted between a string, similar to a password salt (but not really). This is my code: set passSalt to random number from 10000000 to 99999999 do shell script "echo password | shasum -a 512" set passHash to result...

Most efficient way to add filler characters to a string in Applescript?


osx,applescript
I've been working on a script that requires you to enter a username that is always equal to or less than 32 characters. My goal is to add extra characters to the end of the string if it is less than 32 characters. For example, if I used the word...

Generate a Salted Hash in Terminal


hash,terminal,applescript,osx-mavericks
I want to make an AppleScript that generates a salted hash with Terminal. Is there a specific Terminal command that can generate a salted hash, preferably a secure one like SHA-512? If possible, I would like one that's a one-liner so I can use it with the do shell script...

Trouble formatting a string with multiple quotation marks


xcode,swift,terminal,applescript,osascript
I am making a NSTask which runs osascript to gracefully quit an application instead of a killall/kill command. I have this: let killtask = NSTask() killtask.launchPath = "/usr/bin/killall" killtask.launchPath = "/usr/bin/osascript" killtask.arguments = ["-e","'quit app", ""Transmission"""'"] killtask.launch() The troublesome line is the arguments I'm trying to pass. The command in...

Apple script Global variable not working when executing the service using a keyboard shortcut


applescript,automator
I have created a service in Automator to open a terminal using a different color schema everytime. global terminalpos on run {input, parameters} try get terminalpos on error set terminalpos to 0 end try set colorsList to {"Pro", "Basic", "Grass", "Homebrew", "Man Page", "Novel", "Ocean", "Red Sands", "Silver Aerogel", "Solid...

“Foundation” framework can be used in AppleScript on Yosemite but not Mavericks


applescript,server
I've written an AppleScript library that makes use of the "Foundation" framework. On one computer (with Mac OS X Yosemite), everything runs fine. On my other computer (which runs Mac OS X Mavericks), I'm getting an error. When digging deeper to check what the issue is, it seems that the...

AppleScript : keystroke : too slow


applescript,keystroke
The keystroke on my script take around 5/7 seconds until going to the next step. I didn't set any delay. E.g : -- Click 1 click pop up button 1 of group 2 of group 2 of group 1 of group 2 of group 6 of group 2 of group...

Variables with On/End Statements in AppleScript


variables,applescript,osx-mavericks
I'm experimenting with on and end statements in AppleScript. Consider the following script. set mytext to "Hello, World" on greeting(mytext) display dialog mytext default answer "" set othertext to text returned of result end greeting greeting(mytext) say othertext I want to carry over the variable mytext into greeting and I...

How can I check for existence of Itunes track in Applescript without throwing error


applescript,itunes
the idea of this script (simplified to show the issue) is checks if a track exists, tell application "iTunes" set matchtrack to get first track in playlist 1 whose persistent ID is "F1A68AD90AA66648" if matchtrack is not {} then print name of matchtrack else print "no track found" end if...

AppleScript : can’t set clipboard to


applescript,clipboard
I know this is probably really stupid But I can't sent a variable to the clipboard I still have the error message "can’t set clipboard to " I try to set the result as a variable and set the variable as text, string, Unicode text, but always the same issue...

Hard link breaks after changing original (AppleScript .scpt) file


applescript,inode
I have an AppleScript Library file (.scpt) saved in ~/Library/Script Libraries which I use to call handlers from, in other scripts. I want also want to keep that file as part of a git repository. So my idea was: create a hard link in ~/Library/Script Libraries to the file in...

How to use “move…” verb to move sheets in Numbers?


applescript,applescript-numbers
I'm trying to figure out how to re-position sheets in Numbers. There is no way to insert things at specific location so I am hoping that I can find another way. The move verb drew my attention (it is in the Numbers dictionary) however there is little or no information,...

Use one terminal instance for many do shell scripts?


shell,ssh,applescript
So, I need to make an AppleScript to ssh into my mint headless server. I don't need to transfer files, just run commands. The issue is, when I ssh with one do shell script, it is in a separate instance than the others. Also, bonus if I don't have to...

How do you make a repeat command on applescript activated by a button?


applescript
I have a applescript code to make a choose your own adventure game. I want to make a command to repeat the entire code when a button is clicked. This is all the code I have: set volume 3 beep set volume 5 delay 0.5 beep set volume 7 delay...

Moving a file into a folder with Applescript


applescript
I'm fairly new to learning applescript, and I'm trying to set up something for my school's announcement system in order to make it more automated. This is supposed to take the current date, check if a folder for the month exists, and if it doesn't- create one. Then it should...

How to click a button that's only visible when hovered over?


osx,applescript
I'm tinkering with an applescript that would clear notifications from Notification Center. At this point cannot figure out a way to click the clear button. You see, the button only appears if cursor is hovering on the row of the app, or rows below that belongs to this app. I...

Search a custom property


applescript
I am using AppleScript to search through a bunch of my contacts, with a specific (custom) property. Here is my code: tell application "Address Book" set allPeople to every person whose last name = "CERTAIN_LAST_NAME" get properties of item 1 of allPeople end tell The specific last name is just...

How to customise notification in os x using applescript


osx,notifications,applescript
Say I have a file sometext.txt . I want the contents of this txt file to show up in the notification which I will trigger using displaynotification in applescript. In other words I want to be able to: display notification "File's content" with title "Title". How can I do it?...

sending Apple event to console application


applescript,appleevents
I have console app named "MyApp" it is running and I see it in the activity monitor. I'm writing in AppleScript Editor the script: tell application "MyApp" display dialog "Hello World" end tell When running the script the editor asks me where is MyApp? And it doesn't appear in the...

OS X Script Editor - Open 3 images in 1 Photoshop file


image,osx,applescript,photoshop
Working in Script Editor, I have been trying to make an script that opens three selected JPEG files into a single Photoshop document. I'm trying to arrange them one by one in a line. The code I wrote opens them, but in separate documents. This one is AppleScript, any other...

Applescript, Chrome: Make new tab at specified index


applescript
I have this simple Applescript, which reopens active tab in new tab tell application "Google Chrome" tell first window set theUrl to URL of active tab set myTab to make new tab at end of tabs set URL of myTab to theUrl end tell end tell So I can open...

Automator: Choose from list and getting the corresponding variable value


osx,applescript,automator
I'm new to AppleScript but I do have some basic knowledge of Automator. Here is what I want to achieve: There is a simple list of URLs that I often use throughout my work. Like this: Product datasheet: URL1 Licensing: URL2 Price list: URL3 ... etc. In most cases I...

AppleScript throwing errors on curly braces in string


shell,applescript,curly-braces
I'm trying to generate a shell script in AppleScript. When using the following pattern: set tDur to "PT1H21M7S" set tSh to "echo '" & tDur & "' | egrep -o '[0-9]+M' | sed s/M// | sed -e :a -e s/^.\{1,1\}$/0&/;ta" ...I get the error: Expected “"” but found unknown token....

How to pass date information to AppleScript?


swift,applescript,nsapplescript,nsappleeventdescriptor
I am making one app that can run AppleScript via NSAppleScript. Everything had been fine but I haven't been able to figure out how to pass date information from my app to AppleScript. (Since AppleScript has date type, I suppose this is possible) The way I pass parameters to AppleScript...

How to use a command line argument of apple script in do script?


applescript
In terminal.app I am executing the command. osascript filename.scpt 'argument1' 'argument2' The filename.scpt script will set it's variable named scriptName from the second argument it receives when run from the CL. set scriptName to item 2 of argv The filename.scpt will then use the variable scriptName in a do script...

How can I call brew from an Applescript


osx,applescript,homebrew
I'm trying to create a script to check if Homebrew is installed on any given mac and in case it is if it has a particular formula installed. I have the part that checks if brew is installed, but when I try to run brew list to see what packages...

Apple Script : Cleaning textedit text


text,applescript,textedit
I want to clear some text from a textedit text but its only half working for me tell application "TextEdit" set documentText to text of document 1 set {oldTID, my text item delimiters} to {my text item delimiters, "Administration"} set textBits to text items of documentText set my text item...

Resize images to specific width only (AppleScript or Automator)


image,osx,applescript,image-resizing,automator
I've been searching google.com a couple of hours trying to find a way to do this, but there is no answer. Everywhere is resize to the longest size, but nothing about resize to the specified width only. Is there any way in Automator or AppleScript to resize images to a...

Click “See All” Link in iTunes with AppleScript


applescript,automator
I am trying to use AppleScript to navigate iTunes. This is working thus far, but I am having trouble clicking the "See All" link/text (image below). You may note that there are two "See All" links, one for iPhone and one for iPad. I am trying to click the one...