Copy folders and subfolders only

I am looking for a method to copy the entire folder structure(only) from one network drive to another.  I do not want any files copied, just the folders and subfolders.

If there is a program that can do this effectively, I am open to that.

Some of these folders may have subfolders levels that go 5-6 levels deep.

Thanks for any suggestions?
Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
XCOPY /T /E can do that for you, as in:

XCOPY x:\fromdir y:\todir /T /E

You can see other options by doing:

XCOPY /?

»bp
0
Author Commented:
Thanks
0
EE Solution Guide - CEO Faru Bonon ITCommented:
And the powershell form:

$source="D:\Cloud\OneDrive - J0rt3g4 Consulting Services\Odesk"$target="f:\test"

Get-ChildItem -Path $source -Recurse -Directory | %{ [System.IO.Directory]::CreateDirectory("$target$($_.FullName.Replace($source,""""))") }  0 Technical Specialist/DeveloperCommented: robocopy c:\Folder1 c:\Folder2 /e /xf *  0 Experts Exchange Solution brought to you by Your issues matter to us. Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle. EE Solution Guide - CEO Faru Bonon ITCommented: Bill, you need to change the$source and $target. I did run the script again and it worked like a charm. I'm using powershell v5. $source="D:\Cloud\OneDrive - J0rt3g4 Consulting Services\AllFotosHistorical"
$target="f:\test" Get-ChildItem -Path$source -Recurse -Directory | %{
[System.IO.Directory]::CreateDirectory("$target$($_.FullName.Replace($source,""""))")
}


Even from this question I made a script on technet.

https://gallery.technet.microsoft.com/scriptcenter/Create-Folders-structure-6bb190c5?redir=0
0
Commented:
Jose,

My version:

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      16299  98


I had changed the variables used in your script, as follows.  Both these folders exist, the first has a number of subfolders, the other is empty.  Still no love here, I just get errors when I run your original script.  If you say it works for you I believe you, but it doesn't go so well here...

»bp
0
EE Solution Guide - CEO Faru Bonon ITCommented:
Ok Bill,
Try this,
$source="D:\Cloud\OneDrive - J0rt3g4 Consulting Services\AllFotosHistorical"$target="f:\test"

Get-ChildItem -Path $source -Recurse -Directory | %{$tmp = "$target$($_.FullName.Replace($source,""""))"
Write-host "Creating Folder ""$tmp""" -ForegroundColor Gray [System.IO.Directory]::CreateDirectory($tmp)  | Out-Null
}


Let's see how is that $tmp var going for with you We are in same version Name Value ---- ----- PSVersion 5.1.16299.98 0 Commented: PS C:\Users\bprew>$source="c:\temp"
$target="\\ds\bill\ee\temp3" Get-ChildItem -Path$source -Recurse -Directory | %{
$tmp = "$target$($_.FullName.Replace($source,""""))" Write-host "Creating Folder ""$tmp""" -ForegroundColor Gray
[System.IO.Directory]::CreateDirectory($tmp) | Out-Null } Creating Folder "\\ds\bill\ee\temp3C:\temp\.vs" Exception calling "CreateDirectory" with "1" argument(s): "The given path's format is not supported." At line:6 char:2 + [System.IO.Directory]::CreateDirectory($tmp)  | Out-Null
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : NotSupportedException

Creating Folder "\\ds\bill\ee\temp3C:\temp\bb2"
Exception calling "CreateDirectory" with "1" argument(s): "The given path's format is not supported."
At line:6 char:2
+     [System.IO.Directory]::CreateDirectory($tmp) | Out-Null + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : NotSupportedException  »bp 0 Commented: Looks like a bug, concatenating the full path instead of relative? Creating Folder "\\ds\bill\ee\temp3C:\temp\.vs"  »bp 0 EE Solution Guide - CEO Faru Bonon ITCommented: Yeah, also I got errors when the target is a network address. I will fix that later .. It's nice to have other people to test your code. Ty bill. tried this (and worked): $source="D:\Cloud\OneDrive - J0rt3g4 Consulting Services\AllFotosHistorical"
$target="\\172.16.16.10\public\te" Get-ChildItem -Path$source -Recurse -Directory | %{
$tmp = "$target$($_.FullName.Replace($source,""""))" Write-host "Creating Folder ""$tmp""" -ForegroundColor Gray
if(Test-Path $tmp){ New-Item -ItemType Directory -Path "$tmp" | Out-Null
#[System.IO.Directory]::CreateDirectory(\$tmp)  | Out-Null
}
}


still needs to get exception managed but whatever :) will look at later.
1
Commented:
Welcome, wasn't trying to exclude your answer, I like the variety of various approaches.  So I decided to test them all expecting all to work before I recommended a close.  Glad something useful came of that, keep up the good work!

»bp
1
EE Solution Guide - CEO Faru Bonon ITCommented:
Could you please try to test this?
https://gallery.technet.microsoft.com/scriptcenter/Create-Folders-structure-6bb190c5?redir=0

hopefully it will work.

Jose
0
Commented:
Jose,

No luck with that either.

»bp
1
Commented:
I'll stand by my original recomendation in #a42463053.

»bp
0
Author Commented:
sorry for the delay.  Robocopy is what I did use.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Networking

From novice to tech pro — start learning today.