be
In batch dir /b, wildcard ? unavoidably snags some unacceptable results;
therefore in batch I need to use instead an equivalent powershell command.
This line
>powershell "dir -directory -include ???-?? |select fullname"
gives correct results.
However, they are preceded by two preamble lines
FullName
--------
bad for the further processing.
Question is how to get clean output
(not how to clean the output).
Last edited by be (25 Jan 2019 04:44)
----------------------------
# 25 Jan 2019 11:46
Simon Sheppard
You can remove those lines by piping to format-table -HideTableHeaders
so
Code: Select all
PS C:\> dir -directory -include ???-?? | select fullname | format-table -HideTableHeaders
A better approach - you can put the list of files into a variable with:
Code: Select all
$files = dir -directory -include ???-?? | select fullname
Code: Select all
$files
To display the list without any header line, explicitly request just that one property:
Code: Select all
$files.FullName
----------------------------
#25 Jan 2019 12:17
XPlantefeve
To answer precisely your question : select -ExpandProperty fullname
But Simon is right: if you're trying to manipulate strings, you don't have the correct mindset. Forget about batch and jump on the PowerShell bandwagon.
----------------------------
#25 Jan 2019 15:27
be
Reply, everything in it, is excellent.
----------------------------
#25 Jan 2019 15:51
be
Good.XPlantefeve wrote:
select -ExpandProperty fullname
I seek to avoid having to manipulateXPlantefeve wrote:
if you're trying to manipulate strings
On target nonetheless. Taken to heart.XPlantefeve wrote:
jump on the PowerShell bandwagon
----------------------------
#25 Jan 2019 16:54
Simon Sheppard
Good point, I didn't realise that also removed the headers - learn something new every day!XPlantefeve wrote:
To answer precisely your question : select -ExpandProperty fullname