Copying File to a Selected Folder

Hi,
I'm trying to make a macro to copy selected files to a selected folder (always same folder).
How can I do it?
Thank you.
Guillem

Try this.

How did you do this?
Thomas

Thank you for your answer, Gregwarrior, but still I don't know how to do it.
Maestrokeyboard is no that easy for me.

Guillem

1 Like

No problem @Guillem & @Schnell_Thomas... we all started small :wink:

Just click on the macro link here and it will be imported into your Keyboard Maestro Editor. Please don't forget to activate it.

Copy to folder.kmmacros (2,1 KB)
Copy%20to%20folder

You only need to create a folder in the Finder where you want to copy the files. Then please select the Finder folder in the KM macro.
For a better understanding, here is a short video tutorial:

2018_12_30%20Support%20

If you have any questions, please contact me.

1 Like

really cool! thx @appleianer!

can one also use the to path and auto create a dated folder when i copies the file?

ie something like

where the %DATE is the current ISO date?

thx!

Z

Hi @zeltak, I can help you with that. Before I send you a macro I wanted to ask if you use TextExpander, aText, Typinator etc. on your Mac?

I @zeltak use a macro to quickly and efficiently organize my desktop.
I create a folder with date and title from a selection of files and move it to mine. GTD folder to be able to arrange them at the end of the day.

In my example, I've now stuck with your wish to "copy the files to a folder in the Finder".

Of course you can change the date format (red arrow).

GTD Eingang : KM Date.kmmacros (3,9 KB)

59%20PM

2019_01_01%20Support%201

However, I prefer a solution where I can use a KM popup window to select a specific date format via a TextExpander snippet.
The advantage is also that I can have the TextExpander window displayed in the middle of my desktop, which makes my input more comfortable.
At 27 inches a blessing for my eyes :wink:

2019_01_01%20Support%204

Thx alot @appleianer, really appreciate you answer and help!

i have a few issues with this method.
fitst of all it dosent seem to reliably work here. also if i try and copy a file right after that there is a folder name conflict.
most important issue is that i want to to copy the folder to a different location and then create a folder there (with the date)

so the ideas scenario can be seen in this workflow example

go to ~ in finder.
stand on ~/.emacs.d/
issue the macro
the ~/.emacs.d/ is copied to ~/BK/emacs/01012019/

i thought perhaps there was a placeholder for date/time one could enter in the path for the copy/move dialog? like this:

image

if not is it worth putting in a feature request :D?

thx again

Z

Hey Z,

You can do something like this:

Copy File to Dated Backup.kmmacros (6.2 KB)

-Chris

There is. Use this token:
%ICUDateTime%yyyy-MM-dd%

image

thx @JMichaelTX and @ccstone this is exactly what i was looking for!

in a related question. i wonder why using a variable to be used to create a folder name wont work. i have this:

it gives me an error and wont copy it to a folder named %Variable%Name%

yet it does work in the display text and show the correct value for %Variable%Name%

any clue?

best

Z

Hey Z,

The example I gave above does use variables.

You didn't provide a downloadable macro, so we can't fully see what you've done or test it.

Best guess is that either you've fouled up the path in a way you're not seeing – or there's already a file at the destination.

Keyboard Maestro will NOT overwrite files for safety sake.

You have to delete them manually before using a move/copy/create action.

OR you have to resort to the shell.

-Chris

sorry @ccstone for not posting the full macro
attached is the macro as requested
i tried to used your example with the variables but cant get it to work

thx again for all your help

Copy to BK.kmmacros (3.0 KB)

Z

Hey Z,

Your problem becomes pretty evident when you run this version on a single selected file:

Copy the path out of Keyboard Maestro and paste into BBEdit, so you get a nice mono-space-font view of it.

If that's not clear report back, and I'll walk you through it.

-Chris


Copy to BK -- ccs -- 01.kmmacros (4.7 KB)

thx again!

i guess im an idiot and you will have to walk me through :smiley: :smiley:

the display text does seem to show the correct use of the path+date

~/ZH_tmp/ctest/CCtest/2019-01-07/

so im not sure what im missing :smiley:
thx
Z

Hey Z,

I went back and looked at your original question again. Apparently I misread it and missed the auto-create part.

Keyboard Maestro cannot auto-create folders during a copy or move action.

If the folder does NOT exist you cannot copy or move to it.

Sorry for the confusion.

So – you either need to employ a New Folder Action or resort to the shell.

Personally I like to use mkdir -p in the shell, because it creates intermediate directories at need and fails silently if the directory already exists.

(There's also an AppleScriptObjC routine for this.)

-Chris

1 Like

cool! i come from years in the linux world so i know and like the mkdir -p command :smiley:
can the shell command take the %ICUDateTime%yyyy-MM-dd% and %variable%Path% inputs?
and if so would you mind pasting an example?

Though of course it can check for the existence of such a folder, and create it if necessary...

Hey Z,

No.

But you can read Keyboard Maestro variables in the shell.

Execute a Shell Script

See the “Using Keyboard Maestro Variables” section.

You can also use date in the shell of course:

date "+%Y-%m-%d"

-Chris