How can I send file to U-disk quickly?

In Windows, when a udisk is mounted, the right-button menu will have a option “send to yor udisk”.
This is rather simple and good idea. How can I use KM to achieve this? (quickly send files to newly mounted udisk?)

I don't know what a udisk is, but there is descriptions of how to work with selected files in the Finder at:

You would have to know (or the macro would have to figure out) what the destination volume is.

http://mp3support.sandisk.com/downloads/kb/win8/transfer-to-disk/send-to.jpg

It is like this. the destination does not exist before a udisk is mounted.

By "udisk", do you mean a USB external disk, like a thumbnail drive?

If so, you can use AppleScript to get a list of all external drives, and check to see if your drive is available. If so, then copy the file to that drive.

Assuming you just want to copy it to the first ejectable disk, you can use the file actions I refered to earlier, you just need the path to the first ejectable disk.

You can get the URL of the first ejectable disk with:

tell application "Finder"
	URL of first disk whose ejectable is true
end tell

but I can’t figure out an easy way to convert a URL into a file path. Hopefully someone else will chime in with that and then it could all be put together.

1 Like

Peter, I'm not sure that is a good strategy.

I have a "permanent" large external drive that is almost always connected to my Mac. It is ejectable. So if I connect a second external drive, most likely that is the one I want to copy to.

I think a better approach would be to either:

  • Identify the external drive by name in the script
    OR
  • Present the user with a list, and ask him/her to choose.

You could add that as an exclusion. I hate to imagine what the AppleScript would look like, but essentially:

the first disk whose ejectable is true and name is not "My Normally Mounted Disk".

For most people that would be all they would want.

But certainly you could do different solutions.

That is one possibility.

The more i think about it, the more I like giving the user a list of external drives to choose from. Otherwise, users will end up copying (or worse moving) their files to some unexpected location.

If the user has an external drive they always want to use to copy/move, then they can specify the name of that drive in the macro/script, and be assured of where the files go.

Assuming that a "udisk" is an USB external disk, you can use this macro/script to list all ejectable disks, and choose the one you want to use.

##Macro Library   @Send (Copy) File to @External Drive @Example


####DOWNLOAD:
<a class="attachment" href="/uploads/default/original/2X/5/5a0be5e0b9c99895205f7fda43490d21eb838ffb.kmmacros">@Send (Copy) File to @External Drive @Example.kmmacros</a> (2.4 KB)

---

###Example Output
<img src="/uploads/default/original/2X/3/3862173270e7c0cda9b50f912005c8ca0d068c29.png" width="291" height="207">

After macro completes, the Finder will be opened to the selected disk.

---

###ReleaseNotes

**HOW TO USE**

* Assign a trigger to this macro
* Select the file you want to send (copy) in the Finder
* Trigger this macro

---

<img src="/uploads/default/original/2X/e/eeb2828f62620fd8f487c37b25dd129c89bb5873.png" width="588" height="708">

---

###AppleScript
```applescript

tell application "Keyboard Maestro Engine" to set sendToDiskStr to getvariable "DND__SendToDiskName"

tell application "Finder" to set diskList to name of every disk whose ejectable is true

if diskList does not contain sendToDiskStr then set sendToDiskStr to first item of diskList

tell application (path to frontmost application as text)
  set sendToDisk to choose from list diskList with title "Ejectjable Disks Available" with prompt "Select Disk to COPY Your File to:" default items sendToDiskStr
end tell

if sendToDisk is not false then
  
  tell application "Finder"
    set extDiskVol to (sendToDisk as text) & ":"
    set fileList to selection
    set fileToCopy to item 1 of fileList
    duplicate fileToCopy to extDiskVol
    
    open extDiskVol
  end tell
  
  tell application "Keyboard Maestro Engine" to setvariable "DND__SendToDiskName" to sendToDisk as text
end if

```

thans a lot,you are very warmhearted!