r/windows 2d ago

General Question Is there anyway to combine the content of a set of folders into another set of folders (More exp. on desc.)

Imagine you have folder A and folder B, folder A contains in it folders 1, 2 and 3; folder B also contains folder called 1, 2, 3; for reference I'll call them A1, A2 A3 for folder and B1, B2, B3 for folder B; is there anyway to combine folder A and folder B (Or their contents) in a way that folder A1 combines with B1, A2 combines with B2 and A3 combines with B3?

In this context I call "combining" moving all files from folder A1 to B1 and all files with repeated name get overwritten by the folder A1 file.

we suppose both A and B have other folders that are not repeated between them and the same for folders like A1 with B1, A2 with B2, A3 with B3...

Or do I have to do by hand 969 folders?

1 Upvotes

8 comments sorted by

6

u/NETkoholik 2d ago

Isn't the default behaviour of Windows Explorer to merge (or ask before merging) folders nowadays?

1

u/superluig164 2d ago

Yeah I'm pretty sure it is, and even if it doesn't ask, it does merge folders. The easiest way to do this would just be to copy one of the top level folders one level up, rename it to the same as the other folder, and put it back in.

2

u/unndunn 2d ago edited 2d ago

In PowerShell:

Copy-Item Path\to\FolderA\* Path\to\FolderB -Recurse -Force -WhatIf -Verbose

Should accomplish what you want. (The -WhatIf switch means it will tell you what it will do, but not actually do it. Remove the -WhatIf switch to make it actually do the thing).

Alternatively, also in PowerShell,

robocopy C:\Path\to\FolderA C:\Path\to\FolderB /E /L

(The /L switch means it will tell you what it will do without actually doing it. Remove the /L switch for it to actually do the thing. The /E switch means copy subdirectories).

Please back up both folders before running these commands.

The robocopy command is probably better, as it is designed to compare the source and target folders and will make intelligent choices on whether a file needs to be copied or not. It's also multithreaded so it works faster. By contrast, the Copy-Item command is a brute-force command that will simply copy everything.

1

u/mortadeloyfile 2d ago

Sorry if this is not the correct r/, did not know.

1

u/[deleted] 2d ago

[removed] — view removed comment

1

u/AutoModerator 2d ago

Hi u/godplaysdice_, your comment has been removed because it includes a link shortener. Using link shorteners to obfuscate URLs or embed affiliate links is not allowed, so delete this comment and post it again without the link shortener in it.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/LeaveMickeyOutOfThis 2d ago

You might want to look into Windows Libraries.

1

u/redrider65 1d ago

I keep FreeFileSync around for such tasks. Fast, reliable, pause & resume.