[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. @echo off
  2. set n=2
  3. for /f "delims=" %%F in ('dir /b /a-d *.ini') do (
  4.     (for /f "usebackq delims=" %%i in ("%%F") do (
  5.          set "str=%%i"
  6.          setlocal enabledelayedexpansion
  7.          if "!str:\pos=(!" neq "%%i" (
  8.             for /f "tokens=1,2 delims=,)" %%a in ("!str:*\pos(=!") do (
  9.                 set /a "i=%%a*n,j=%%b*n" 2>nul&&(
  10.                     for /f %%j in ("\pos(!i!,!j!)") do (
  11.                         set "str=!str:\pos(%%a,%%b)=%%j!"
  12.                     )   
  13.                 )
  14.             )
  15.         )
  16.     for /f "delims=" %%i in ("!str!") do endlocal&echo %%i
  17.     ))>$
  18.     move $ "%%F"
  19. )
  20. pause
复制代码

TOP

回复 4# yearharvest
  1. @echo off
  2. set n=2
  3. for /f "delims=" %%F in ('dir /b /a-d *.txt') do (
  4.     (for /f "delims=" %%i in ('type "%%F"^|findstr /n .*') do (
  5.         set "str=%%i"
  6.         setlocal enabledelayedexpansion
  7.         if "!str:\pos=(!" neq "%%i" (
  8.            for /f "tokens=1,2 delims=,)" %%a in ("!str:*\pos(=!") do (
  9.                set /a "i=%%a*n,j=%%b*n" 2>nul&&(
  10.                    for /f %%j in ("\pos(!i!,!j!)") do (
  11.                        set "str=!str:\pos(%%a,%%b)=%%j!"
  12.                    )
  13.                )
  14.            )
  15.         )
  16.           echo;!str:*:=!
  17.           endlocal
  18.      ))>$
  19.           move $ "%%F"
  20. )
  21. pause
复制代码

TOP

回复 8# yearharvest
没什么好办法 如你所说 CMD不支持浮点,要么这样,1.5 你当作 15 去乘 然后除以10
1.5*32= 15 *32/10 = 48 这样近似了

TOP

本帖最后由 terse 于 2013-11-4 15:28 编辑

搞个PS练手
XP系统需安装有POWERSHELL win7自带无需另装
代码第一行 2.89 为设定数 自己修改
路径为 c:\test
对于编码的判断准确与否 没测试 运行请前先备份
  1. $n=2.89
  2. function Get-Encoding ($ph)
  3. {
  4. $ByteStr = Get-Content $Ph -Encoding Byte -TotalCount 3
  5. $BOM = "{0:X}{1:X}{2:X}" -f $ByteStr
  6. if ($BOM -eq "EFBBBF") { "UTF8" }
  7. Else {
  8.        $BOM = "{0:X}{1:X}" -f $ByteStr
  9.        if ($BOM -eq "FFFE") { "Unicode" }
  10.            Elseif ($BOM -eq "FEFF") {"BigEndianUnicode"}
  11.            Else {"Ascii"}
  12.        }
  13. }
  14. get-childitem "c:\te st\*" -include *.txt | ?{
  15. $Encoding = Get-Encoding($_)
  16. (Get-Content $_ | % {
  17.     if ($_ -cmatch '(.+\\pos\()(\d+),(\d+)(.*)') {
  18.        "$($matches[1])$([int]($n * $matches[2])),$([int]($n * $matches[3]))$($matches[4])"
  19.     } else {"$_"}
  20. }) | Set-Content  -Encoding $Encoding $_
  21. }
复制代码

TOP

路径和文件扩展名 统一在前面定义
楼主没回复 浪费脑细胞
  1. $n = 2.89
  2. $Ph = "c:\test"
  3. $Ext = "txt"
  4. function Get-Encoding ($ph)
  5. {
  6. $ByteStr = Get-Content $Ph -Encoding Byte -TotalCount 3
  7. $BOM = "{0:X}{1:X}{2:X}" -f $ByteStr
  8. if ($BOM -eq "EFBBBF") { "UTF8" }
  9. Else {
  10.        $BOM = "{0:X}{1:X}" -f $ByteStr
  11.        if ($BOM -eq "FFFE") { "Unicode" }
  12.            Elseif ($BOM -eq "FEFF") {"BigEndianUnicode"}
  13.            Else {"Ascii"}
  14.        }
  15. }
  16. get-childitem "$Ph\*" -include *.$Ext | ?{
  17. $Encoding = Get-Encoding($_)
  18. (Get-Content $_ | % {
  19.     if ($_ -cmatch '(.+\\pos\()(\d+),(\d+)(.*)') {
  20.        "$($matches[1])$([int]($n * $matches[2])),$([int]($n * $matches[3]))$($matches[4])"
  21.     } else {"$_"}
  22. }) | Set-Content  -Encoding $Encoding $_
  23. }
复制代码

TOP

回复 18# yearharvest
新建 ! % ^ & 文件夹 (2)).txt
新建 ! % ^ & 文件夹 (2).txt
将你的附件 另存为上面两个文件 没提示错误
我再看看

TOP

回复 20# yearharvest
如此含中括号文件名还真不知道怎么处理 我发去PS版看下
不知还存在其他问题不  比如编码

TOP

回复 28# yearharvest
http://bbs.bathome.net/thread-27238-1-1.html
虽然结贴了 还是PS 写了个 就不再这里贴了 链接里看下吧

TOP

回复 32# yearharvest
关于PS的解 在29楼链接里有改进的
如方便的话 可再测试看有无其他问题,不便的话或其他原因也就算了

TOP

返回列表