1301
General Software Discussion / Re: I need help creating a new Directory structure including files from a text file.
« Last post by 4wd on July 18, 2016, 03:58 AM »I think it would be a lot easier to do it using Powershell, look at the commandlets:
Import-Csv (read the CSV file)
New-Item (create folder structure)
Copy-Item (copy file to destination or use Move-Item)
This Stack Overflow post pretty much answers how to do it in Powershell:
http://stackoverflow...v-file-in-powershell
To get you started, this will create a folder structure using the info in the CSV:

No error checking or pre-existing path checking.
The second item in the CSV isn't needed, you only need to copy/move the original file (third item) to the new structure.
Import-Csv (read the CSV file)
New-Item (create folder structure)
Copy-Item (copy file to destination or use Move-Item)
This Stack Overflow post pretty much answers how to do it in Powershell:
http://stackoverflow...v-file-in-powershell
To get you started, this will create a folder structure using the info in the CSV:
Code: PowerShell [Select]
- $path = "k:\test.csv"
- Import-Csv -path $path | ForEach-Object {
- $stuff = ($property.Value).Split(",")
- New-Item -Path ("K:\DATABASE DATA\" + $stuff[0]) -ItemType Directory | Out-Null
- }
- }
No error checking or pre-existing path checking.
The second item in the CSV isn't needed, you only need to copy/move the original file (third item) to the new structure.

Recent Posts




