2

How can I Filter Files Name and Complete Files Path Using powershell select-object expand property here is files in partition

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----          3/9/2021   1:14 AM            pics
-a---         1/14/2021   4:35 PM      59929 151104051548IMG_20151103_112015.jpg
-a---         1/14/2021   4:35 PM      80949 151104051558IMG_20151103_123234.jpg
-a---         1/14/2021   4:35 PM      85725 151104051610IMG_20151103_123249.jpg
-a---         1/14/2021   4:35 PM      80519 151104051640IMG_20151103_123924.jpg

Command to Filter Files Name

PS O:\> dir | select -expandproperty name

Output

pics
151104051548IMG_20151103_112015.jpg
151104051558IMG_20151103_123234.jpg
151104051610IMG_20151103_123249.jpg
151104051640IMG_20151103_123924.jpg
151104051658IMG_20151103_130741.jpg
151104051712IMG_20151103_130756.jpg
151104051721IMG_20151103_131053.jpg
151104051853IMG_20151103_090959.jpg

But I also want Full Files Paths with Every File Name i am using this command but receiving an error

PS O:\> dir | select -expandproperty Name,FullName
Or
PS O:\> dir | select -expand Name,FullName
Or 
PS O:\> dir | %{$_.Name} %{$_.FullName}

Error:

Select-Object : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'ExpandProperty'. Specified method is not supported. At line:1 char:30

How can i filter multiple Properties Values is there any simple way? i want only values excluding properties names like

Mode                LastWriteTime     Length Name
----                -------------     -----------

want output something like this:

151104051548IMG_20151103_112015.jpg   o:\151104051548IMG_20151103_112015.jpg 
151104051558IMG_20151103_123234.jpg   o:\151104051558IMG_20151103_123234.jpg 
151104051610IMG_20151103_123249.jpg   o:\151104051610IMG_20151103_123249.jpg
Sadam
  • 144

2 Answers2

2

This should print it how you want:

get-childitem "O:\" | % { Write-Host $_.Name,$_.FullName }

And if you want all files, for example, even in the \pics\ folder, you can add -recurse right before the pipe.

get-childitem "O:\" -recurse | % { Write-Host $_.Name,$_.FullName }

Narzard
  • 3,840
1
$> dir . | select name, fullname | ogv
$> get-childitem . | select name, fullname | out-gridview
user1390375
  • 111
  • 2