本帖最后由 再世情緣 于 2014-8-4 01:56 编辑
回复 16# 思想之翼
综合了之前那位朋友的方法,之后生成了目前的代码,但是,还是不可避免的要call一次。。。。- @echo off &setlocal enabledelayedexpansion &color 0a
- set "var=%cd%"
- set "file1=文本"
- set "file2=文件夹"
- pushd %var% >nul
- for /l %%i in (1,1,9999) do (
- if exist "!file1!%%i\*.txt" (
- set "f1=!file1!%%i"
- set "f2=!file2!%%i"
- mkdir "!f2!" >nul 2>nul
- call :head
- )
- )
- pause.
- call exit
-
- :head
- for /f "delims=" %%a in ('dir /b /a -d /s "%f1%\*.txt" 2^>nul') do (
- set "txtpath=%%~fa"
- set "txtname=%%~nxa"
- call :main !txtpath!
- rem pause.>nul
- )
- rem pause.
- goto :eof
-
- :main
- for /f "usebackq tokens=3 delims= " %%a in ("%1") do (
- set "code0=%%a" &&set "code0=!code0: =!"
- set "code=!code0:*●=!" &&set "code=!code!#a9876543210"
- for /f "usebackq skip=1" %%a in ("%1") do (
- set "code2=%%a" &&set "code2=!code2: *=!"
- set /a "len=0x!code:~10,1!","len0=11-len"
- call :getnum
- )
- )
- echo.当前处理文件:[!txtname!]
- echo.获取第一行有效字符:[!code0!]
- echo.获取第二行有效字符:[!code2!]
- echo.第一行 ● 所在位置:!len0!
- echo.第二行第 !len0! 个字符为: [!num!]
- echo.写入 [!num!] -^> "%cd%\!f2!\!txtname!"
- (echo.!num!)>"%cd%\!f2!\!txtname!"
- goto :eof
-
- :getnum
- set "num=!code2:~-%len%,1!"
- goto :eof
复制代码
|