Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Recursively list file paths to excel column separating with delimiter

$
0
0

Hi guys,

I'm trying to export all .jpg file paths of a directory recursively with a separating delimiter (chose pipe character) such that each sub folder's file contents (.jpg file paths) are listed as new cell in a column.

So imagine we are in directory:


X:\My\Files


This folder contains the following folders and files



Folder1\img1.jpg
Folder1\img2.jpg
Folder2\img3.jpg
Folder2\img4.jpg


What I want the output to be


X:\My\Files\Folder1\img1.jpg|X:\my\Files\Folder1\img2.jpg ## 1st cell of csv column
X:\My\Files\Folder2\img3.jpg|X:\my\Files\Folder2\img4.jpg ## 2nd cell of csv column


My command so far


(Get-ChildItem -Path X:\My\Files -Include *.jpg -Recurse) -join "|" | Add-Content -path C:\Users\Anon\Documents\file.csv | Select-Object FullName


This is able to get me all file paths separated with pipe delimiter, but only into one cell which is useless. I need it to respect directory structure like listed above in my desired output.

Any advice?


Viewing all articles
Browse latest Browse all 6937

Trending Articles