[FINDER] Move Selected Finder Items to Choose Folder [Example]

MACRO:   [FINDER] Move Selected Finder Items to Choose Folder [Example]

2017-02-11 12:10 CT

  • Add better error handling
  • Add prefix of "MSF__" to all KM Variables used in this macro
    (all variables are deleted at end of macro)

~~~ VER: 1.1    2017-02-11 ~~~

DOWNLOAD:

[FINDER] Move Selected Finder Items to Choose Folder [Example].kmmacros (21 KB)


You may also be interested in:
MACRO: Move List of Items Selected in PathFinder


ReleaseNotes

Author: @JMichaelTX

PURPOSE: MOVE Items in Finder Selection to Destination Folder Chosen by User

HOW To USE:

  1. Select one or more items (files and/or folders) in the Finder
  2. Trigger this Macro
  3. MOVE will be CANCELED if the User cancels the Choose Folder script, OR clicks on "Stop" in the "Confirm Move" alert.

Note that the App focus starts on the Finder, and remains the same after the macro completes.

BASED ON THIS USER QUESTION:

Can KM display a set of folders, say all folders in the Documents folder or a list of folders (or alias of folders) I create in the Documents folder (or some other folder) that when I click on a folder within that set of displayed folders will move a previously selected file in the Finder to that folder and return me back to the folder I made the file selection from?

REF: Simplifying Filing: Move Selected Finder File to “Pick-A-Folder”
Simplifying Filing: Move Selected Finder File to "Pick-A-Folder"

REQUIRES:
(1) Keyboard Maestro Ver 7.0.3+
(2) Yosemite (10.10.5)+



Example Results

5 Likes

Hi @JMichaelTX

I get a strange result here

The variable DestinationFolder is getting set to that location in /Library inside theSCRIPT: Choose DESTINATION Folder script. If I extract that script and run it in Script Debugger, I don’t get this result. I’m not using DestinationFolder in any other macro, and even when I add an action to Set Variable 'DestinationFolder' to Text' (setting it to an empty string), I still get the weird result. Something is going on with the script in the action but I haven’t been able to isolate it.

I’ve left ParentFolder set to ~/Documents which is fine for me. That bit is working OK.

I’ve rebooted several times, and get the same result. Not sure why iMindMap’s QuickLook generator has anything to do with anything here, and I’ve definitely never grabbed its file:// path for any reason.

I’m sure it’s something very obvious that I’m fat fingering or ignoring :frown:

What folder are you choosing for the Destination Folder?
I need this so I can test.

Is this happening for all choices of Destination Folder?

Hey @JMichaelTX

Thanks for replying. I’m using ~/Desktop and subfolders of ~/Documents. If I extract your script “Choose DESTINATION Folder” entirely and run it in Script Debugger I have no errors. For example, the value returned in destinationFolder is ~/Desktop, or whatever I choose in the dialog. I don’t know if that’s useful info.

Just updated the macro in the above post.

@korm, please download and try the updated macro.
The KM Variable "DestinationFolder" is now named "MSF__DestinationFolder".
Perhaps there was some conflict with the original name.

Please let me know if this fixes your issue.

1 Like

Hey @JMichaelTX -- it does fix it. Thanks so much for your help. I like this macro.

Next thing I plan to do is extend the macro to grab the lists of Favorites and Recent destinations from Default Folder X and optionally offer them as destinations for your move macro. I'll post my update whenever I have a chance to do those mods.

(Sorry I cannot mark your reply as a solution -- since I'm not the OP in this thread -- but kudos anyway :smile:)

1 Like

That sounds great!
I suggest that you post it as a new topic in the "macro" section, with a link back to here.
That will help others find your macro easier.

Great macro! I’ve posted it here: https://cafetran.freshdesk.com/support/discussions/topics/6000051701

I have a lot of project folders and it can take some mouse actions to scroll down to the right one. Would it be possible to add an incremental search for the project folder name? E.g. I start typing m,u,e to have the project folder mueller selected? Or would that require a full blown app? ;).

Anyway, many thanks for this nice macro.

I just had an idea: When I switch the View mode to the List display instead of the [||_] one (don’t know what it’s called), then the problem is solved. So I’ll google for how to switch to this List display ;).

It’s at easy as using this AppleScript:

tell application “Finder” to ¬
set the current view of the front Finder window to list view

Is this what you are looking for?
KM can perform Applescripts

A good solution for this is to make a set of macros with the same trigger, each of which moves the files to a specific folder. Then Keyboard Maestro will use the Conflict Palette to let you select the desired folder.

I have this set up on Control-F in the Finder:

Pressing S would eliminate all the others and let me choose an account with C/M/S.

2 Likes

I've got a huge folder of PDF books that I want to organize. To start with I want to categorize the books into big folders like FRENCH, MATHEMATICS, and so on. So far, those aare the only two I've tried.

I changed this action to hard-code the destination folder to either FRENCH or MATHEMATICS, based on whether I press one key chord or another.

For some reason, to move five or six files, this action takes fifteen to twenty seconds.

The only non-standard thing I'm coping with is that the files are in a Dropbox folder that I have mounted using an app called Cloud Mounter. So my destination folder looks like:

~/Library/Containers/com.eltima.cloudmounter.mas/Data/.CMVolumes/Dropbox/Books/Math

Still -- seems like I could just open a few windows and drag and drop if each small set of files is going to take so long to move.

What might I be doing wrong?

This is very unusual. I've moved lots (>50) files with this and it is fast.
But maybe there is something with your setup/use case that is much different.

To analyze, we need more info:

  1. If you manually move the same group of files, how long does it take?
  2. How large are these PDF files?
  3. Have you tried moving to a non-Dropbox location?

Hey @JMichaelTX, I'm playing with Path Finder. How does this need to be modified to work with it? I added "The running applications" to the For each collections in the Move Each Item in Finder Selection... action but it's not that easy. Maybe some directions for me to begin to understand this macro or a fix if you'd rather not get into teaching mode? I'm guessing the MSF_FinderItem variable doesn't see the selection when the section is within Path Finder. Maybe replace it with MSF_PathFinderItem or does the coding of this whole action include the Finder in a way that makes it unusable with Path Finder?

Hey Bern,

Search for "Path Finder" and "AppleScript" on the forum and see if you can answer your own question.

If not then report back, and we'll help.

-Chris

See

MACRO: Get Text List of Items Selected in PathFinder

Thank you @JMichaelTX , I pulled the various pieces together and to my surprise it worked. It's now a tool I'm going to get a lot of mileage out of.

@ccstone , I read all the items that that search brought up. While I could get the gist of what was being said, there are too many holes in my understanding to use those pieces. What one book would you recommend to begin learning AppleScripting?

I'm going to either going learn enough to be able to use the support generously offered here or just hire someone to write whatever code I need. I have no commitment to this inbetween place my current level of understanding leaves me.

1 Like

Chris may have a different suggestion, but I would not start with a book.
If you are new to AppleScript and are interested in learning more, then I'd suggest you take a look at:

Learning AppleScript

  1. AppleScript: Beginner's Tutorial at macosxautomation.com
  2. Script Debugger 7 -- a full IDE for developing AppleScript.
    SD7 now comes with a 20-day free trial, and then will gracefully downgrade to the FREE SD7 Lite (which is still much better than Script Editor).

You can get lots of AppleScript help here in this forum, and in the Script Debugger Forum.

If you really want a book, I like, and have used (mostly before I discovered Ref #1), this book:
Learn AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X, 3rd Edition, Kindle Edition by Hamish Sanderson (Author), Hanaan Rosenthal (Author)

1 Like

I agree with what JM says, but I might recommend “AppleScript 1,2,3” by Sal Sohogian and Bill Cheeseman. Unfortunately I haven't had my hands on this, although I broke down and ordered a used copy.

“Learn AppleScript...” is one of the better books, but I think the other one might be good for beginners. I'll have a better opinion next Tuesday or Wednesday.

-Chris

Macro works great, thanks!
Is there an easy way to have finder go to that folder after moving the files and also select them?

I know this is old, but you could add an Open a File, Folder or Application action to the end of your macro!