I'm trying to find a way to copy a folder's attributes such as the hidden flag and creation date to a different folder. Alternatively, I'd like to create a new folder that mimics the structure of an existing folder but without copying any of the content. I've been exploring Robocopy for this, but I'm having some trouble. For instance, when I use the command `robocopy C:Source C:Dest`, it doesn't create the destination folder itself, so I could use some guidance. Any tips?
3 Answers
For creating an empty folder structure, try this PowerShell script. It replicates the folder under a new parent. You just need to define the top-level source and the new destination. It finds all the directories and creates them without copying any file content. Here's a quick snippet:
```powershell
$top_level_path = "C:pathtosource"
$new_top_level_path = "C:pathtonew"
Get-ChildItem -Path $top_level_path -Recurse -Directory | ForEach-Object {
$newPath = $_.FullName -replace [regex]::Escape($top_level_path), $new_top_level_path
New-Item -Path $newPath -ItemType Directory -ErrorAction SilentlyContinue
}
```
This should create your desired folder structure!
You can actually use Robocopy to replicate the folder structure without the files. To copy the hierarchy without content, just ensure you're specifying the destination with the full folder name. This will bring over the structure you're looking for! If you're aiming for specific attributes, consider using the `/create` flag to avoid unwanted data copying. Just remember to adjust your destination correctly.
If you want to ensure you’re including specific attributes with Robocopy, make sure to use `/COPYALL`. This will grab everything. However, if you only want certain attributes like the date and hidden flag, you can specify them individually with `/COPY:DATSOU`, which allows you to exclude the data. So for your needs, try `/COPY:ATSOU` to exclude files.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically