bokee.net

大学生博客

正文 更多文章

批量修改文件内容(pro/e批量安装)

     本脚本,可在机房内批量修改ProE。pro/e 5.0免安装版以测试

@echo off

rem QQ:289605631
setlocal enabledelayedexpansion
set "Space=        "
set "PH_addr=%Space%Physical Address"  %
Rem ========set "IP_addr=%Space%IP Address" %
Rem ===========主程序===================
for /f "tokens=1,* delims=." %%i in (’ipconfig /all’) do (
   for %%a in (PH_addr IP_addr) do (
      if "%%i"=="!%%a!" set %%a=%%j
   )
)
Rem ’/*===========对结果进行处理===========
set PH_addr=%PH_addr:*:=%
Rem ========set IP_addr=%IP_addr:*:=%
echo.
echo 你的网卡物理地址为:%PH_addr%
pause
echo. =================去除MAC空格=======================
set "str=%PH_addr%"
for /f "tokens=* delims= " %%a in ("%str%") do call :ie "%%a"
goto :eof

:ie str
set "var=%~1"
if "%var:~-1%"==" "  call :ie "%var:~0,-1%"
Rem ===================================================
echo.
Rem ========内容替换=================
set file=LICENSE.DAT
rem ======================要操作的文件名称(包括扩展名LICENSE.DAT)
set "file=%file:"=%"
for %%i in ("%file%") do set file=%%~fi
echo.
set replaced=00-1D-7D-18-8D-56
ren===== 注意其中"set replaced=00-1D-7D-18-8D-56",中的00-1D-7D-18-8D-56为你破解文件中的MAC地址
rem set /p replaced= 请输入即将被替换的内容:
echo.
set all=%var%
for /f "delims=" %%i in (’type "%file%"’) do (
    set str=%%i
    set "str=!str:%replaced%=%all%!"
    echo !str!>>"%file%"_tmp.txt
)
copy "%file%" "%file%"_bak.txt >nul 2>nul
move "%file%"_tmp.txt "%file%"
start "" "%file%"

rem=================复制以上内容,保存为cmd。增加到启动目录中======================

                                                                                                                                            Am

 ======================以下内容为此脚本大部分内容来源===========================

1.提取MAC地址
::code by youxi01@ 2008-1-5
@echo off
setlocal enabledelayedexpansion
title 获取本机IP(局域网)及MAC地址@来自
Rem ’/*=========初始化设置=============*/
set "Space=        "
set "PH_addr=%Space%Physical Address"   %’/*-----物理地址-------*/%
set "IP_addr=%Space%IP Address" %’/*------IP地址(局域网)--------*/%
Rem ===========主程序===================
for /f "tokens=1,* delims=." %%i in (’ipconfig /all’) do (
for %%a in (PH_addr IP_addr) do (
   if "%%i"=="!%%a!" set %%a=%%j
)
)
Rem ’/*===========对结果进行处理===========
set PH_addr=%PH_addr:*:=%
set IP_addr=%IP_addr:*:=%
Rem ’/*===========结果输出===============
echo.
echo 你的网卡物理地址为:%PH_addr%
echo.
echo 你的IP(局域网)地址为:%IP_addr%
pause>nul

 2.去掉字符串的空格

ren  来自/viewthread.php?tid=453&extra=page%3D199%26amp%3Borderby%3Ddateline%26amp%3Bascdesc%3DDESC&page=1

@echo off
set "str=    abc d  "
for /f "tokens=* delims= " %%a in ("%str%") do (
        set "var=%%a"
        call :ie
    )
echo.
echo  去除空格前:  [%str%]
echo.
echo  去除空格后:  [%var%]
echo.
pause&goto :eof


:ie
if "%var:~-1%"==" " (set "var=%var:~0,-1%"&goto ie) else goto :eof

3.内容替换

rem 来自/lvshu_198511/blog/static/4077233020097534915699/

@echo off
setlocal enabledelayedexpansion
set file=
set /p file=  请输入要操作的文件名称(包括扩展名):
set "file=%file:"=%"
for %%i in ("%file%") do set file=%%~fi
echo.
set replaced=
set /p replaced= 请输入即将被替换的内容:
echo.
set all=
set /p all=  请输入替换字符串:
for /f "delims=" %%i in (’type "%file%"’) do (
    set str=%%i
    set "str=!str:%replaced%=%all%!"
    echo !str!>>"%file%"_tmp.txt
)
copy "%file%" "%file%"_bak.txt >nul 2>nul
move "%file%"_tmp.txt "%file%"
start "" "%file%"

============================================================

分享到:

上一篇:IE

下一篇:Word-删除某文档中某字符(回车符