I would like to be able to write a PowerShell script that would take a folder (or set of folders) and to duplicate them in which the folder structure (without the files) could be created, where the file structure (without the folders) could be created, or in which both the files (all or selected ones) AND folders could be created.
Example:
C:\ProdData has 3 subfolders in it
C:\ProdData\Fld1
C:\ProdData\Fld2
C:\ProdData\Fld3 - has 2 subfolders under it
C:\ProdData\Fld3\MyFolder1
C:\ProdData\Fld3\MyFolder2
Each folder above has a various number of files of various sizes in it, of various file extensions.
I would like to have a PowerShell script that would duplicate that folder structure elsewhere, giving me a choice of Folder Structure Only, Files Only, or Files AND Folders to be copied.
In the above, I'd like to be able to copy C:\ProdData to another folder, essentially renaming ProdData to TestData (that is, C:\ProdData copied to C:\TestData), or to copy the entire folder structure.
C:\ProdData
into another folder that is a subfolder of something else: C:\TestArea\TestFolders\2012-04-01\TestData\ProdData\Fld1
, etc...
And selectively choose to include folders, files or both.
The ideal solution would be to (for folders only) take the folder structure, export/save it, read it in, and create that same structure elsewhere. Some solutions I've found said they copied the folder structure only, but if data exists, that gets copied also and you can't exclude one or the other. I have a partial solution to the files-only requirement that semi-preserves the path, but it would take a file:
c:\ProdData\Fld1\MyFile.dat
and copy it to:
c:\TestData\yyyyMMdd_hhmmss_ProdData_Fld1_MyFile.dat
But that's not something that could easily be decoded and would be impossible to re-integrate the source structure. I'd appreciate any thoughts about how to accomplish this without re-inventing the wheel.