Working on a recent project, I was using PowerShell to manipulate a list of MS Word documents that I had to process. Reading other articles on the Internet, I realised how useful it would be if I could create a list of files of interest in a CSV file and import this into Microsoft Excel in the usual way.
Although the example given is looking at PDF files, the principle is the same.
$inputPath='C:\pdf_files'; $outputCsv='C:\temp\pdfs.csv'; Get-ChildItem -Path $inputPath -Filter *.pdf -Recurse | Select-Object DirectoryName, Name, LastWriteTime | Export-Csv -Path $outputCsv -Encoding ascii -NoTypeInformation;
The Select-Object Cmdlet is used to select the file attributes I want in my CSV file.
Keywords: powershell csv import