[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 newswan 于 2023-4-21 01:04 编辑
  1. $fld = "."
  2. if ( $fld -like "?:*" ) {
  3. $p = $fld
  4. } else {
  5. $p = Join-Path $PSScriptRoot $fld
  6. }
  7. Set-Location $p
  8. [string]$p = Get-Location
  9. Get-ChildItem -Recurse -Directory $p | ForEach-Object {
  10. if ( -not ( Get-ChildItem -Directory -Path $_.fullname )) {
  11. $p2 = $_.fullname.Substring( $p.Length +1 )
  12. $NewName = Join-Path $_.Parent.FullName ( $p2 -replace "\\","-" )
  13. Write-Host "--" $_.fullname.Substring( $p.Length +1 )
  14. write-Host "  " $NewName.Substring( $p.Length +1 )
  15. # Rename-Item $_.fullname -NewName $NewName
  16. }
  17. }
复制代码
第一行是 要处理的目录
如果正确 删除17行前的#

TOP

返回列表