简体   繁体   中英

export folders list in specific pattern PowerShell

I need to export a list of folders in a specific pattern my code is

$list = Get-ChildItem -Path c:\test\  -Directory | Select-Object BaseName 

I need the final output to be.

<object> folder name here </object>

so I can use it later to update an xml file I have

how can i do it?

$list = Get-ChildItem -Path d:\tmp\  -Directory | Select-Object @{name="baseNameInTag"; expression = {"<object>{0}</object>" -f $_.BaseName}}

选择对象

(Get-ChildItem -Directory c:\test).BaseName |
  ForEach-Object { "<object>$_</object>" }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM