Pages

9/19/2014

Powershell: Get list of files in folder

Create a list of all files in a folder. Maybe in preparation for processing each file.

$workdir = "c:\parse"
$inputdir = $workdir + "\input"

# Get file listing
if (-not (test-path $inputdir)) {
 "Folder:  $inputdir"
 "Does not exist!"
 exit
 }

$files = get-childitem $inputdir -name
if (-not ($files)) {
 "Folder:  $inputdir"
 "Contains no files!"
 exit
 }

No comments: