Jump to content

Copy & Paste (Or Move) A Folder and Merge the Contents.

Recommended Posts

In macOS's finder, when I drag a folder named "X" from one location to another while holding the Option key, I am presented,  if that second location already contains a folder named "X," with a dialogue box asking me to choose between "Stop," "Replace," and "Merge." 


Most often, I wish to merge the contents of the two folders; is there a way to accomplish this using Alfred? Even more ideally, I'd like to be able to cut and merge, so that the folder is moved (rather than copied) from its original location.


If I attempt to use Alfred's Universal Action "Move to," then the folder is not moved—it remains in its original location—and with "Move [with Replace]," the contents of the existing folder are overwritten. 


Any ideas?




Link to comment
3 hours ago, exposition said:

I'd like to be able to cut and merge, so that the folder is moved (rather than copied) from its original location.

This is actually very easily accomplished with a workflow. First, to get some idea take a look at my rather more complex Move to new folder workflow on the Alfred Gallery. That will provide the basics—although what you want to do is rather simpler to achieve.


In essence you'll start with the first four actions of my workflow (as far as and including Set the base path variable) but then you'll use an Automation Task Move Path With The Finder checking Replace file with same name at destination. You'll use the previous variables saved for the Path: and Move To: fields, of course.


I've actually already created and tested the workflow but thought you might learn more by creating it for yourself. If that's unduly cruel and unhelpful let me know and I'll add the workflow somewhere from where you can download it. 😁



Link to comment

Thanks; I'd like to learn!


I've almost got it working, but it's asking me to type the name of the new folder. As the name of the folders can sometimes be quite long, I'm hoping the workflow can automatically use the name of the original folder.


Is there a way to modify the "Set the new folder name variable" and "Create new folder path variable" such that they don't depend on the result of the "Ask for the name of the new folder" but instead take the name of the original folder?


To this end, I tried removing "Ask for name of new folder" and modifying "Create new folder path" to build the path based on "theInput" variable, but the workflow is giving me the following error in the debugging log:



ERROR: Move to new folder - COPY[Automation Task] Task Argument Error: Expecting single or multiple inputs. Warnings: (
    "Passed in file '/Users/me/Downloads/move folder test/new folder/Users/me/Downloads/move folder test/old folder' does not exist, discarding"


It seems it's just piecing together the original path and the destination path, and I'm not sure what to do next... I guess 'theInput' needs to be something else? Something that doesn't include the entire path but simply the folder's name. 


Thanks again!







Ah, and these are what I have the fields for "Move Path With the Finder": 





Edited by exposition
Additional information.
Link to comment
1 hour ago, exposition said:

've almost got it working, but it's asking me to type the name of the new folder.

I understood from your original post that you wanted to move one existing folder (folder 1) into another existing folder (folder 2). I rather overlooked the wish to merge files in folder 2 with those in folder 1 in the process: sorry! That is certainly more complex and, in the middle of breakfast, I can't think of an immediate, easy solution. No doubt someone else will come along with one if I can't think of anything later.


Sorry not to be more helpful just now.



Link to comment

@exposition I should have a (slightly complex!) workflow for you to play with in the next hour or so. I just need to write the Read Me explaining how it works. However, please initially test very carefully the merge files option. I have checked it and it seems to work properly but make backups of the folders you're testing before using it for the first few times.



Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...