I'm trying to figure out how to copy a folder's attributes, like the hidden flag and creation date, to another folder or to simply replicate a folder structure without transferring any of its contents. I thought about using Robocopy, but it doesn't seem to create the destination folder when I'm trying to copy. For example, if I run Robocopy from C:Source to C:Dest, it won't create the C:Dest folder itself. Is there a way to do this effectively?
3 Answers
Make sure to adjust your Robocopy command to include the necessary attributes. Try `/COPYALL` to include all attributes, or if you want to specify, use `/COPY:DATSOU` and leave out the ones you’re not interested in. For just replicating the folder without data, you can opt for `/COPY:ATSOU` instead!
If you're using PowerShell, you can achieve this by replicating the folder structure with some script. Use `Get-ChildItem` to grab all directories you want to copy and then create new folders at your desired location. Here’s a sample code to help you out!
$top_level_path = "C:Userspathtotop"
$new_top_level_path = "C:Usersnewpathtop"
$sub_paths = Get-ChildItem -Path $top_level_path -Recurse -Directory
foreach ($path in $sub_paths)
{
$new_path = $path.FullName -replace "C:\Users\path\to\top", $new_top_level_path
if (!(Test-Path -Path $new_path))
{
New-Item -Path $new_path -ItemType Directory
}
}
You can actually use Robocopy for this! You need to specify the destination with the exact name of the source folder to copy the whole structure without the files. This should work for your case where you want to maintain the folder hierarchy. Just make sure you're directing it properly!
But keep in mind it doesn't copy the root folder itself. Using the `/create` flag can replicate the hierarchy, but it doesn’t give you the root folder. I've also noticed it creates 0 KB files, which is not what I want either. I'm really just after copying the main folder without any contents or attributes.

Totally agree! Robocopy is a powerful tool for this.