1
我在E:\ MyFiles \和E:\ MyFiles \ August中有文件。我正在使用PowerShell将文件路径存储在csv文件(E:\ CSVPaths.csv)中。System.Object [] - 当文件名相同时
这是我的脚本:
$exclude = @(".html", ".tt", ".xaml", ".csproj", ".sln", ".xml", ".cmd", ".txt",".svn")
"DirectoryPath, SourceFileName" | Out-File -FilePath "E:\CSVPaths.csv" -Encoding ASCII
$table = (get-childitem -recurse "E:\MyFiles" -File -ErrorAction SilentlyContinue | Where-Object { $exclude -notcontains $_.Extension }).Fullname
foreach ($row in $table)
{
$file=Get-ChildItem -recurse $row
$fileObject = new-object PSObject
$fileObject | add-member -membertype NoteProperty -name "DirectoryPath" -Value $file.DirectoryName
$fileObject | add-member -membertype NoteProperty -name "SourceFileName" -Value $file.Name
$newrow=$fileObject
Export-Csv "E:\CSVPaths.csv" -inputobject $newrow -append -Force
}
在这两个E:\ MYFILES和E:\ MYFILES \文件夹月,有同名文件(例如:Audit_Report.csv)。虽然出口到它们被存储为System.Object[]
在DirectoryPath
和SourceFileName
CSV(如下所示):
DirectoryPath SourceFileName
System.Object[] System.Object[]
E:\MyFiles\August Audit_Report.csv
请帮助解决这个问题。
_shell script_?你的意思是PowreShell? – Clijsters
@Clijsters:Powershell – user3189916