Change Directory in the Finder

shellscript
applescript

#1

Hi all

i wanted to have a quick way while in finder to change directories via keyboard.
I couldnt find anyway way in KM or in the finders keybinds to do it , so up with this uber crude way:

anyone can think of a better way of doing so without multiple binds+pauses :smiley: :smiley:

also would be cool to maybe create a pre defined list of places and use that for changing dir, copying to the predefined locations etc..anyone know of such an example?

best

Z


#2

Using shell script is faster than keystroke

open /Users/$(whoami)/Downloads/

#3

Without a modifier key, D could be a trouble when you want type in the letter instead of using it as a trigger.


#4

I would do it like this:

Keyboard Maestro 8.2.4 “Open users download folder in Finder” Macro

Open users download folder in Finder.kmmacros (1.7 KB)


#5

wow thx guys!

cant believe i missed the open command in KM @JimmyHartington :smiley:

@suliveevil the open CLI option is also great!

thx again

Z


#6

And this will present you with at box, where you can start to write the name of the folder you want to open.

Just change the list to add folders.

Keyboard Maestro 8.2.4 “Open folder” Macro

Open folder.kmmacros (3.3 KB)


#8

@JimmyHartington..wow!!!!
this is the stuff dreams are made of lol :wink:

thx so much. in a related question then, can one use this to instead open a path rather move a selected file to one of the targets in that list you presented?

thx again so much!

Z


#9

You are welcome.


#10

Is it one selected file or multiple?
A mix of files and directories?

I would like to give it a shoot when I am back at my computer.


#11

Hey Z,

I see you're trying to change the directory of the front Finder window.

AppleScript makes that pretty easy.

----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2019/01/09 16:27
# dMod: 2019/01/09 16:27 
# Appl: Finder
# Task: Change the Target of the Front Finder Window
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Finder, @Change, @Target, @Front, @Window
----------------------------------------------------------------

set newTarget to path to downloads folder

tell application "Finder"
   if window 1 exists then
      tell window 1
         if (its target as alias) ≠ newTarget then
            set its target to newTarget
         else
            beep 2
         end if
      end tell
   end if
end tell

----------------------------------------------------------------

Jimmy's “Open folder” macro could easily be repurposed to do this as well.

What locations specifically?

Easily.

-Chris


#12

Here is my attempt with a macro, which moves the selected file/files to the folder you choose.
It does not work on with selected folders.

And as @ccstone writes, I did not notice you wanted to change directory. My solutions opens a new window in Finder.

Keyboard Maestro 8.2.4 “Move selected file to folder” Macro

Move selected file to folder.kmmacros (3.8 KB)


#13

thx alot @JimmyHartington thats perfect for me!

Z


#15

JimmyHartington:

This macro does not work for me. Everytime I run it, I get the error message

"Macro Cancelled
Open File failed with non-existent path
,’%Variable%LocaLFoldcrToOpen%,,. Macro "Open Fo..."

How do you get it to actually open the folder?


#16

In the error message there seems to be a typo.
Have you copied the error message in or written it?


#17

I copied it.

The good news is that I just tried it again, to verify the error message, and the darn thing worked. Have tried it twice more and it works. So I'm at a loss as to why it repeatedly failed before. I tried it at least 10 times before and it failed every time, no matter what folder I tried.

If it fails again, I'll let you know.

Thanks for the reply.


#18

@zeltak, If one of the above posts solves your problem/question as originally stated, please check the "Solved" checkbox (click for details) at the bottom of that post.

Otherwise, please post your remaining questions/issues about this problem.
If you have other questions, please start a new topic.


#19

sure thing, done!

th @JMichaelTX for letting me know about this

Z