【问题标题】:Can I run a Windows Powershell command matching all files in the current directory and all subdirectories?我可以运行与当前目录和所有子目录中的所有文件匹配的 Windows Powershell 命令吗?
【发布时间】:2021-09-27 14:33:21
【问题描述】:

我的文件结构如下:

maindir/
  - subdir/
      - file1.ts
      - file2.ts
  - file3.ts
  - file4.ts

我正在尝试使用 ts-interface-builder 构建 typescript 接口,我想匹配并构建所有 4 个 file*.ts 文件。 (ts-interface-builder只是构建类型,这个问题主要是关于Windows Powershell中的匹配模式/通配符,因为我习惯了Unix)。

我目前正在使用这个命令:

npx ts-interface-builder ./maindir/*.ts

但这只会构建file3.tsfile4.ts。 我可以使用稍微不同的命令:

npx ts-interface-builder ./maindir/*/*.ts

但它只构建file1.tsfile2.ts

我尝试研究 Windows Powershell 通配符,但无法弄清楚。 是否有一个 single 命令可以用来构建所有 4 个文件?

【问题讨论】:

    标签: regex windows powershell wildcard


    【解决方案1】:

    假设你的npx 命令是由 / 从 PowerShell 执行的:

    npx ts-interface-builder (Get-ChildItem ./maindir -Recurse -Filter *.ts).FullName
    

    另请参阅:Get-ChildItem cmdlet。

    【讨论】:

      猜你喜欢
      • 2011-03-07
      • 1970-01-01
      • 2012-02-07
      • 2016-07-04
      • 1970-01-01
      • 1970-01-01
      • 2014-05-03
      • 2016-08-20
      • 2017-11-19
      相关资源
      最近更新 更多