Copy 2 levels of parent directory with files?

Get help for specific problems
Posts: 4
Joined: 6 Aug 2025

mlitty

I want to pull the final products of projects out of a tree into a target folder that has the project folder and the output.
It would look like this…
Source
D:*\Admissions\Undergrad Admit\output\*.*
D:*\Student Affairs\Campus Rec\output\*.*
D:*\Advancement\Alumni Affairs\output\*.*


Target
F:Finals\Undergrad Admit\output\*.*
F:Finals\Campus Rec\output\*.*
F:Finals\Alumni Affairs\output\*.*
I have hundreds of projects so manually creating each target folder would be tedious at best.
Or… does anyone know a Windows 11 terminal command that would accomplish this? I can’t install software and I can’t run as admin because it’s a work computer.

Thanks.
User avatar
Posts: 2946
Joined: 22 Aug 2012

Plerry

Perhaps I misunderstand you.
All your source references start with D:*\.
Does this mean that the path that this first * stands for can be different for each of your source/target pairs?
Is there a single path matching the * in D:*\ for each of your source/target pairs? Or can there be multiple path's matching the * in D:*\ for one or more of your source/target pairs?

When assuming all path's matching the * in D:*\ for each of your source/target pairs are the same, i.e. the path to Admissions, Student Affairs, Advancement etc. on your source (D) drive is all the same let's say D:\[PathToSourceFolderParents], I would suggest you use a single left-right pair, syncing
Left D:\[PathToSourceFolderParents] => right F:Finals\
and replace the default Include Filter of * (=everything) by \*\*\output\*.*
This assures that only the contents of your output folders that are at least two levels deep will be synced.

However, this will give you a slightly different result that you describe, as it will
Source
D:\[PathToSourceFolderParents]\Admissions\Undergrad Admit\output\*.*
D:\[PathToSourceFolderParents]\Student Affairs\Campus Rec\output\*.*
D:\[PathToSourceFolderParents]\Advancement\Alumni Affairs\output\*.*


Target
F:Finals\Admissions\Undergrad Admit\output\*.*
F:Finals\Student Affairs\Campus Rec\output\*.*
F:Finals\Advancement\Alumni Affairs\output\*.*
But may be acceptable to you.
I don't see another way to make FreeFileSync (FFS) realize your sync for you.
Posts: 4
Joined: 6 Aug 2025

mlitty

Thank you for responding. You're close.

Yes, the paths are all different and the parent directories of output are all different. The challenge is that I want the different parent directories of the different output folders to copy over as well, without the full directory tree.

Here's a clearer example.
Source: directory tree ending in output\file-names.mp4
D:\administration\chancellor-office\output\speech.mp4
D:\academics\biology\output\lab.mp4
D:\campus rec\flag football\output\tournament.mp4
D:\academics\chemistry\output\classroom.mp4

Target: only the direct parent directory of output then output with its files.
F:\chancellor-office\output\speech.mp4
F:\biology\output\lab.mp4
F:\flag football\output\tournament.mp4
F:\chemistry\output\classroom.mp4

What I don't want is for all of the target files to end up in a single folder called output and I don't want the full directory trees for each file, just a single-level parent.

If this were implemented, a possible filter might be to copy
*\..\output\*.*
to indicated that the parent directory of output should also be copied over but not the directories above the parent directory of output. I haven't tried that yet but that would be one way to implement this.
Posts: 4
Joined: 6 Aug 2025

mlitty

I wish FreeFileSync could do this but, in case someone else comes looking or in case it's useful to developers, I worked with ChatGPT to come up with a Windows PowerShell command that does the trick.
Get-ChildItem -Path "." -Directory -Recurse -Filter "output" | ForEach-Object {
    $parentName = Split-Path $_.Parent.FullName -Leaf
    $dest = Join-Path "F:\TEST" $parentName
    robocopy $_.FullName (Join-Path $dest "output") /E
}
How it works (according to ChatGPT)
• Finds all folders named output from the current folder down.
• Gets the name of their immediate parent folder ($parentName).
• Builds a destination path F:\TEST\<parentName>\output.
• Uses robocopy to copy only the contents of output to that location: outlook, it's direct parent, and the contents of output without the sibling content of output.
Posts: 4
Joined: 6 Aug 2025

mlitty