[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. <#*,:&cls
  2. @echo off
  3. pushd "%~dp0"
  4. powershell -NoProfile -ExecutionPolicy RemoteSigned -Command ". ([ScriptBlock]::Create((Get-Content -LiteralPath \"%~0\" -ReadCount 0 | Out-String ))) "
  5. popd
  6. pause
  7. exit /b
  8. #>
  9. # 文件名 2个及以上字母与2个及以上数字之间添加-
  10. Get-ChildItem -Path . -Filter * | ForEach-Object {
  11.   $newName = $_.FullName -replace '(?<=[a-z]{2,})(?=[0-9]{2,})|(?<=[0-9]{2,})(?=[a-z]{2,})', '-'
  12.   if ($newName -ne $_.FullName) {
  13.     Rename-Item -LiteralPath $_.FullName -NewName $newName -Force -Verbose
  14.   }
  15. }
复制代码
微信:flashercs
QQ:49908356

TOP

本帖最后由 flashercs 于 2020-1-30 00:40 编辑

回复 3# ChenCheChe
  1. <#*,:&cls
  2. @echo off
  3. pushd "%~dp0"
  4. powershell  -NoProfile -ExecutionPolicy RemoteSigned -Command ". ([ScriptBlock]::Create((Get-Content -LiteralPath \"%~0\" -ReadCount 0 | Out-String ))) "
  5. popd
  6. pause
  7. exit /b
  8. #>
  9. # 文件名 2个及以上字母与2个及以上数字之间添加-
  10. Get-ChildItem -Path . -Filter * | ForEach-Object {
  11.   $newName = $_.FullName -replace '(?<=[a-z]{2,})(?=[0-9]{2,})|(?<=[0-9]{2,})(?=[a-z]{2,})', '-'
  12.   if ($newName -ne $_.FullName) {
  13.     Rename-Item -Path ($_.pspath -replace '[\[\]]','`$&') -NewName $newName -Force -Verbose
  14.     # $_.MoveTo($newName)
  15.   }
  16. }
复制代码
微信:flashercs
QQ:49908356

TOP

返回列表