批量提取xx.c xx.h文件并加写成#include ”xx.c“ ,#include "xx.h"格式 / 替换文件名中的字符串 / 文件名添加前缀
1.批量提取xx.c xx.h文件并加写成#include ”xx.c“ ,#include "xx.h"格式
新建”提取源文件.txt“,重命名为”提取源文件.bat“,以记事本打开,写入如下代码,并保存,把”提取源文件.bat“放到需要提取的目录下,双击运行即可。
@echo off
echo "提取xx.c文件..."
for /f "delims=" %%f in ('dir/b/s/a-d *.c') do (if not "%%~nxf"=="%0" echo #include "%%~nxf")
echo "提取xx.c文件完毕!!!"
echo "提取xx.h文件..."
for /f "delims=" %%f in ('dir/b/s/a-d *.h') do (if not "%%~nxf"=="%0" echo #include "%%~nxf")
echo "提取xx.h文件完毕!!!"
pause
2.替换文件名中的字符串
@echo off
echo.&set /p strtemp1= str_before:
echo.&set /p strtemp2= str_after:
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('dir /a /b *.*') do (
set nobird=%%a
ren "%%~a" "!nobird:%strtemp1%=%strtemp2%!")
pause
3. 文件名添加前缀
@echo off
for /f “delims=” %%f in (‘dir/b/s/a-d .’) do (if not “%%~nxf”=="%0" ren “%%f” “BmpTime%%~nxf”)
写博客不容易,需要大家多多支持。想了解更多,本人也可以提供有赏服务