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 

2 Answers

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 }

1
$> dir . | select name, fullname | ogv $> get-childitem . | select name, fullname | out-gridview 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy