简体   繁体   English

以特定模式导出文件夹列表 PowerShell

[英]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.我需要最终的 output 。

<object> folder name here </object>

so I can use it later to update an xml file I have所以我以后可以用它来更新我拥有的 xml 文件

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>" }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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