Need a separate csv for each path.

folder= (Get-Content -Path C:\path.txt)
$CurrentDate = Get-Date
$CurrentDate = $CurrentDate.ToString(‘MM-dd-yyyy_hh-mm-ss’)

Get-ChildItem $folder -include .avi,.m4a,.m4p,.m4v,.mobi,.mov,.doc,.mp3,.mp4,.mpeg,.mpg,.VOB,.wav,.wma,*.wmv -Recurse |

select Directory,FullName,CreationTime,Length | Export-Csv -Path “c:\output\mediafiles_$CurrentDate.csv”


path.txt is below

c:\

c:\wondows

c:\windows\media

Need a separate csv for each path.

You are using recurse but are specifying different sub folders in your input file. Only need one or the other not both. You could just make one big file which includes the path - then you could sort and filter on that. -Include won’t work in the way you are using it
Why take directory and full name - you have redundant information. I’d take either fullname OR directory and Name

If you have to have different files per folder then do something like this

$folders = (Get-Content -Path C:\test2\path.txt)
$exts = “.txt”, “.evt”, “.jpg”, “.png”

foreach ($folder in $folders) {
Get-ChildItem -Path $folder -File |
where Extension -in $exts |
select Directory, Fullname, CreationTime, Length |
Export-Csv -Path “$folder\files.csv” -NoTypeInformation
}

Thanks Richard. I am checking.

It is providing a single CSV not multiple.

Please post the code you are using and the contents of your path.txt file. I tested my code before posting it and it produces one csv per folder in that folder

Script.
workflow media {

Suspend-Workflow
Checkpoint-Workflow

$folders = (Get-Content -Path C:\path.txt)
$exts = “.txt”, “.evt”, “.jpg”, “.png”

foreach ($folder in $folders) {
Get-ChildItem -Path $folder -File |
where Extension -in $exts |
select Directory, Fullname, CreationTime, Length |
Export-Csv -Path “$folder\files.csv” -NoTypeInformation
}

}
path.txt
c:
c:\windows
c:\windows\media

That code won’t work in a work flow because work flows don’t allow aliases or positional parameters. Try the code as I posted, in a normal script. Once that works for you I can show you how to make the workflow work. Also I don’t understand the logic of immediately suspending the workflow

Awesome info Richard. Need resume & suspend during running that script. Please help.