'Copying source files and retaining folder structures including parent folders (but not files)
Say I have the following source and target.
source: c:\temp\folder1\folder2
target: e:\backup
I want to have an output as shown below. As you can see, it should only copy the files and its subdirectories from the above source path but it should also copy/create the parent folders (no files) leading to the source path. How can I accomplish this with Powershell or robocopy? If Powershell doesnt handle long path names then I prefer using Robocopy.
source: c:\temp \folder1 \file1.txt \folder2 \file2.txt \folder3 \file3.txt
output: e:\backup \temp \folder1 \folder2 \file2.txt \folder3 \file3.txt
Solution 1:[1]
If I have understood you right you want to create any missing folders in the output on the fly. In powershell this would be s.t. like this:
Copy-Item c:\temp e:\backup\temp\ -recurse
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | scaler |
