本帖最后由 lxzzr 于 2012-3-4 22:38 编辑
| @echo off | | setlocal enabledelayedexpansion | | | | | | set infile=a.txt | | :: set infile=%1 | | | | for %%i in (%infile%) do set outfile=%%~ni.b64 | | | | echo --->%outfile% | | echo Content-Type: application/octet-stream; name="%infile%">>%outfile% | | echo Content-Transfer-Encoding: base64>>%outfile% | | echo Content-Disposition: inline; filename="%infile%">>%outfile% | | echo.>>%outfile% | | | | set t=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ | | | | for %%i in (%infile%) do set n=%%~zi | | if [%n%]==[0] goto :eof | | set /p=<nul>_.a | | set /p=<nul>_.b | | set /p=a<nul>_.a1 | | set /p=b<nul>_.b1 | | set m=1 | | set /a i=-2 | | | | :loop | | set /a k="%m%&%n%" | | if not [%k%]==[0] copy /b _.a + _.a1>nul | | if not [%k%]==[0] copy /b _.b + _.b1>nul | | set /a k="%i%&%n%" | | if [%k%]==[0] goto :exit | | | | type _.a1>>_.a1 | | type _.b1>>_.b1 | | set /a m=m*2 | | set /a i=i*2 | | goto :loop | | :exit | | | | fc /b %infile% _.a|find ":">_.a1 | | fc /b %infile% _.b|find ":">>_.a1 | | sort _.a1>_.b1 | | set n= | | set m=0 | | set k=0 | | set q=0 | | for /f "tokens=1,2" %%i in (_.b1) do ( | | if not [!n!]==[%%i] ( | | set i=%%j | | call :dig !i:~0,1! | | set /a m=!m!*16+!j! | | call :dig !i:~1,1! | | set /a m=m*16+j | | set /a k=k+1 | | if !k!==3 ( | | set /a p="m>>18" | | call set x=!x!%%t:~!p!,1%% | | set /a p="(m>>12)&63" | | call set x=!x!%%t:~!p!,1%% | | set /a p="(m>>6)&63" | | call set x=!x!%%t:~!p!,1%% | | set /a p="m&63" | | call set x=!x!%%t:~!p!,1%% | | set /a q=q+1 | | if [!q!]==[18] ( | | echo !x!>>%outfile% | | set x= | | set q=0) | | set m=0 | | set k=0)) | | set n=%%i) | | | | if [%k%]==[1] ( | | set /a p="m>>2" | | call set x=!x!%%t:~!p!,1%% | | set /a p="(m<<4)&63" | | call set x=!x!%%t:~!p!,1%%==) | | | | if [%k%]==[2] ( | | set /a p="m>>10" | | call set x=!x!%%t:~!p!,1%% | | set /a p="(m>>4)&63" | | call set x=!x!%%t:~!p!,1%% | | set /a p="(m<<2)&63" | | call set x=!x!%%t:~!p!,1%%=) | | | | if not [%q%]==[0] echo %x%>>%outfile% | | | | echo.>>%outfile% | | echo ----->>%outfile% | | | | del _.a | | del _.a1 | | del _.b | | del _.b1 | | | | goto :eof | | | | :dig | | set j=%1 | | if [%1]==[A] set j=10 | | if [%1]==[B] set j=11 | | if [%1]==[C] set j=12 | | if [%1]==[D] set j=13 | | if [%1]==[E] set j=14 | | if [%1]==[F] set j=15COPY |
|