Skip to main content
TopMiniSite

Back to all posts

How to Copy Folder Structure Only With Powershell?

Published on
4 min read
How to Copy Folder Structure Only With Powershell? image

Best PowerShell Tools to Buy in October 2025

1 Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools

Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools

BUY & SAVE
$47.34 $59.99
Save 21%
Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools
2 Beginner’s Guide to PowerShell Scripting: Automate Windows Administration, Master Active Directory, and Unlock Cloud DevOps with Real-World Scripts and Projects

Beginner’s Guide to PowerShell Scripting: Automate Windows Administration, Master Active Directory, and Unlock Cloud DevOps with Real-World Scripts and Projects

BUY & SAVE
$0.99
Beginner’s Guide to PowerShell Scripting: Automate Windows Administration, Master Active Directory, and Unlock Cloud DevOps with Real-World Scripts and Projects
3 PowerShell for Penetration Testing: Explore the capabilities of PowerShell for pentesters across multiple platforms

PowerShell for Penetration Testing: Explore the capabilities of PowerShell for pentesters across multiple platforms

BUY & SAVE
$47.49 $49.99
Save 5%
PowerShell for Penetration Testing: Explore the capabilities of PowerShell for pentesters across multiple platforms
4 Troubleshooting SharePoint: The Complete Guide to Tools, Best Practices, PowerShell One-Liners, and Scripts

Troubleshooting SharePoint: The Complete Guide to Tools, Best Practices, PowerShell One-Liners, and Scripts

BUY & SAVE
$27.00 $59.99
Save 55%
Troubleshooting SharePoint: The Complete Guide to Tools, Best Practices, PowerShell One-Liners, and Scripts
5 Learn PowerShell Toolmaking in a Month of Lunches

Learn PowerShell Toolmaking in a Month of Lunches

BUY & SAVE
$20.52 $44.99
Save 54%
Learn PowerShell Toolmaking in a Month of Lunches
6 AWS Tools for PowerShell 6: Administrate, maintain, and automate your infrastructure with ease

AWS Tools for PowerShell 6: Administrate, maintain, and automate your infrastructure with ease

BUY & SAVE
$48.99
AWS Tools for PowerShell 6: Administrate, maintain, and automate your infrastructure with ease
7 Learn Windows PowerShell in a Month of Lunches

Learn Windows PowerShell in a Month of Lunches

BUY & SAVE
$34.99
Learn Windows PowerShell in a Month of Lunches
8 PowerShell Advanced Cookbook: Enhance your scripting skills and master PowerShell with 90+ advanced recipes (English Edition)

PowerShell Advanced Cookbook: Enhance your scripting skills and master PowerShell with 90+ advanced recipes (English Edition)

BUY & SAVE
$37.95
PowerShell Advanced Cookbook: Enhance your scripting skills and master PowerShell with 90+ advanced recipes (English Edition)
9 Learn Windows PowerShell in a Month of Lunches

Learn Windows PowerShell in a Month of Lunches

BUY & SAVE
$31.99 $44.99
Save 29%
Learn Windows PowerShell in a Month of Lunches
+
ONE MORE?

To copy folder structure only with PowerShell, you can use the following command:

Get-ChildItem -Path "source_folder_path" -Recurse | Where-Object { $_.PSIsContainer } | foreach { $_.FullName.Replace("source_folder_path", "destination_folder_path") }

Replace "source_folder_path" with the path of the folder you want to copy and "destination_folder_path" with the path of the destination folder where you want to copy the folder structure. This command will recursively get all the folders within the source folder and create the same folder structure in the destination folder without copying the files.

How to copy folder structure only with Powershell from network share?

To copy just the folder structure without the files from a network share, you can use the following PowerShell script:

$sourcePath = "\\Server\Share\Path" # Specify the path of the network share $destinationPath = "C:\Destination\Path" # Specify the destination path

$sourceFolders = Get-ChildItem $sourcePath -Directory -Recurse # Get all the subfolders in the source path

foreach ($folder in $sourceFolders) { $destinationFolder = $folder.FullName -replace [regex]::Escape($sourcePath), $destinationPath New-Item -ItemType Directory -Path $destinationFolder -Force }

Make sure to replace \\Server\Share\Path with the actual network share path and C:\Destination\Path with the desired destination path where you want to copy the folder structure.

This script will recursively go through the source folder and create the same folder structure in the destination path without copying any files.

How to copy folder structure only with Powershell and log results?

To copy the folder structure only with Powershell and log the results, you can use the following script:

$source = "C:\SourceFolder" $destination = "C:\DestinationFolder"

$files = Get-ChildItem -Path $source -Recurse -Directory

foreach ($file in $files) { $destPath = Join-Path -Path $destination -ChildPath $file.FullName.Substring($source.length) Write-Host "Copying $($file.FullName) to $($destPath)"

if (!(Test-Path -Path $destPath)) {
    New-Item -ItemType Directory -Path $destPath | Out-Null
}

}

Write-Host "Folder structure copied successfully."

This script will recursively iterate through all folders and subfolders in the source directory and create the same folder structure in the destination directory. It will log the results of each folder copy operation to the console. You can also redirect the output to a log file like this:

$source = "C:\SourceFolder" $destination = "C:\DestinationFolder" $logFile = "C:\CopyLog.txt"

$files = Get-ChildItem -Path $source -Recurse -Directory

foreach ($file in $files) { $destPath = Join-Path -Path $destination -ChildPath $file.FullName.Substring($source.length) Add-Content -Path $logFile -Value "Copying $($file.FullName) to $($destPath)"

if (!(Test-Path -Path $destPath)) {
    New-Item -ItemType Directory -Path $destPath | Out-Null
}

}

Add-Content -Path $logFile -Value "Folder structure copied successfully."

This will create a log file named "CopyLog.txt" in the specified path and write the results of each folder copy operation to it.

How to copy folder structure only with Powershell without interrupting other processes?

You can use the robocopy command in PowerShell to copy the folder structure without interrupting other processes. Here's an example command:

robocopy source_folder destination_folder /create /e

This command will copy the folder structure from source_folder to destination_folder without copying the actual files. The /create flag tells robocopy to create the folder structure without copying any files, and the /e flag tells robocopy to copy subdirectories, including empty ones.

You can run this command in the background by adding the Start-Process cmdlet before the robocopy command:

Start-Process -NoNewWindow -FilePath robocopy -ArgumentList "source_folder destination_folder /create /e"

This will start the robocopy command in a separate process, allowing you to continue running other tasks in PowerShell without interruption.

What is the fastest way to copy folder structure only with Powershell?

The fastest way to copy folder structure only with Powershell is to use the robocopy command.

Here is an example command that you can use to copy the folder structure only:

robocopy source_path destination_path /e /create

In this command:

  • source_path is the path of the folder whose structure you want to copy.
  • destination_path is the path of the destination folder where you want to copy the structure.
  • /e flag copies all subdirectories, including empty ones.
  • create flag only copies the folder structure without copying any files.

This command will quickly copy the folder structure from the source folder to the destination folder without copying any files.