Hello,
I am unable to find the actions which would allow me to:
- move all files in a folder (for example the scansnap folder)
- into another folder (for example documents folder)
- replace all files in the destination.
thank you
Hello,
I am unable to find the actions which would allow me to:
You would need to use these two Actions in a loop, such as the For Each action with Folder Contents Collection
Note that the Trash File Action has NOT enabled the abort on failure, so that if the file does not exist the macro just continues:
So, putting this all together, it would look something like this:
Be sure to test carefully using test folders/files before using in production.
thank you VERY MUCH for the detailed response.
I will work on trying to understand your reply.
Would allowing for file versioning instead of replace make things easier ?
I am perplexed at how complicated it is. I thought that the answer would be simple and straightforward.
Would the following command line (Terminal) commands do the job assuming I want to move files from Downloads to Scansnap? Could you just add a flag to indicate replace files or allow for file versioning in the destination?
mv ~/Downloads/. ~/Scansnap
rm ~/Downloads/.
I could not find a KBM action to run command line or terminal commands.
thanks again very much for your time and help
See Execute a Shell Script action (KM Wiki)
It doesn't seem complex to me. A loop with 3 statements. <shrug>
I'm sure there are bash commands that will do this. Just do some googling and I'm sure you find them.
This could also be done easily in AppleScript, but it would be about the same number of statements as the KM actions.
thank you very much
Hey @ronald
This largely mindset. If you're used to QuicKeys then you're accustomed to being spoon-fed quite a few functions, and it can be a shock when Keyboard Maestro hands you the spoon and says “Feed yourself!”
Here's a kinder, gentler method using AppleScript:
----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2018/03/11 22:10
# dMod: 2018/03/11 22:14
# Appl: Finder
# Task: Move Files from one folder to another and replace any collisions.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Finder, @Move, @Files,@Folder, @Replace, @Collisions
----------------------------------------------------------------
set sourceFolder to alias "Mercury:Users:chris:test_directory:Test_Move_Files_Source:"
set destinationFolder to alias "Mercury:Users:chris:Downloads:Test_Move_Files_Destination:"
tell application "Finder"
set filesToMoveList to files of sourceFolder as alias list
move filesToMoveList to destinationFolder with replacing
end tell
----------------------------------------------------------------
The same thing can be accomplished via the shell like so:
src='/Users/chris/test_directory/Test_Move_Files_Source/'
dest='/Users/chris/Downloads/Test_Move_Files_Destination/'
cd "$src"
mv -f * "$dest"
Keyboard Maestro's move action will NOT overwrite an existing item, but Bash will when the -f
(force) switch is used.
The above can be written as a one-liner like so:
mv -fv '/Users/chris/test_directory/Test_Move_Files_Source/'* '/Users/chris/Downloads/Test_Move_Files_Destination/'
However – it is easier to make a potentially dangerous mistake when using this form.
When writing shell scripts that can overwrite something it is essential to use great caution, because a small syntax mistake could erase your whole user-directory.
-Chris
Thanks very much.
I will work on decrypting the Apple Script.
The spoon feeding metaphor is excellent !
I have just uploaded a complete macro for transferring (moving) all files from one folder to another, which provides:
See:
I think you will find this a "kinder, gentler," and safer method using mostly native KM Actions.
Please feel free to post in this macro topic with any questions/issues/suggestions.
thanks very much !