批量提取xx.c xx.h文件並加寫成#include ”xx.c“ ,#include "xx.h"格式 / 替換文件名中的字符串 / 文件名添加前綴

批量提取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”)

寫博客不容易,需要大家多多支持。想了解更多,本人也可以提供有賞服務
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章