[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
test.bat
ansi编码,注意备份
  1. #&cls&@cd /d "%~dp0" & powershell -c "Get-Content '%~0' | Out-String | Invoke-Expression" & pause&exit
  2. $shell = New-Object -ComObject 'Shell.Application'
  3. $folder = $shell.NameSpace($PWD.Path)
  4. #打开txt
  5. $txts = Get-Content 'a.txt'
  6. #找索引
  7. $i = $index1 = $index2 = $index3 = $index4 = 0
  8. while(!($index1 -and $index2 -and $index3 -and $index4)){
  9. if($folder.GetDetailsOf($null,$i) -eq '高度'){
  10. $index1 = $i
  11. }
  12. elseif($folder.GetDetailsOf($null,$i) -eq '宽度'){
  13. $index2 = $i
  14. }
  15. elseif($folder.GetDetailsOf($null,$i) -eq '帧高度'){
  16. $index3 = $i
  17. }
  18. elseif($folder.GetDetailsOf($null,$i) -eq '帧宽度'){
  19. $index4 = $i
  20. }
  21. ++$i
  22. }
  23. #重命名
  24. $folder.Items() | foreach {
  25. $__ = $_
  26. $t = $name = $null
  27. if($_.Name -match '^(.*?)\d+\.((png)|(jpg))$'){
  28. $t = '图片'; $name = $Matches[1]; $a = $index1; $b = $index2
  29. }
  30. elseif ($_.Name -match '^(.*?)\d+\.mp4$'){
  31. $t = '视频'; $name = $Matches[1]; $a = $index3; $b = $index4
  32. }
  33. if($t -ne $null -and $a -match '\d'){
  34. $b_find = $true
  35. $txts | foreach{
  36. if($b_find -and ($_ -match ('^{0}\d*,(.*?)$' -f $name)) ){
  37. $h = $folder.GetDetailsOf($__,$a) -replace '[^\d]',''
  38. $w = $folder.GetDetailsOf($__,$b) -replace '[^\d]',''
  39. $new_name = '{0}{1}__123--({2}x{3})——{4}' -f $t,$Matches[1],$h,$w,$__.Name
  40. $__.Name
  41. $new_name
  42. Rename-Item $__.Path $new_name
  43. $b_find = $false
  44. '---------------------------'
  45. }
  46. }
  47. }
  48. }
复制代码
1

评分人数

    • czvde: 乐于助人技术 + 1

TOP

回复 11# czvde


    图片,视频,a.txt,bat文件
    都放在一个文件夹里运行

TOP

回复 13# czvde


    测试正常,你只有想其他办法了

TOP

返回列表