优秀的编程知识分享平台

网站首页 > 技术文章 正文

Notepad++批量打开文件,批量查找、替换和设置编码格式

nanyue 2024-08-22 17:36:07 技术文章 6 ℃

notepad++可以批量打开文件,

如果有路径列表的文件,也可以利用代码指打开:

	string lineFile;
	ifstream ifs("D:\\websiteHtmlBackup\\temp.txt");
	while(!ifs.eof())
	{
		getline(ifs,lineFile);
		CString np = "F:\\Website\\notes\\tools\\npp\\notepad++.exe";
		ShellExecute(NULL, "open", np, lineFile.c_str(), NULL, SW_SHOWNORMAL);
	}
	ifs.close();

文件列表可以用批处理建立:

@echo off
setlocal enabledelayedexpansion
echo.>fileList.txt
color 3a
echo.
echo 系统正在查找文件,请耐心等候......
echo.
::for %%a in (C D E F) do (
for %%a in (F:\Website) do (
cd /d %%a\
	for /r %%b in (*.htm) do ( ::包括*.html 
		if exist "%%b" (
			echo %%b
			echo %%b>>fileList.txt
		)
	)
	for /r %%b in (*.css *.js) do (
		if exist "%%b" (
			echo %%b
			echo %%b>>fileList.txt
		)
	)
for /r F:\website\witiso\zfirst %%b in (*) do (
	if exist "%%b" (
		echo %%b
		echo %%b>>fileList.txt
	)
)
type fileList.txt | find /i "\" && goto no
echo.
echo 文件内容没找到!
del fileList.txt>nul 2>nul
echo.
pause
exit
:no
::cls
echo.
echo 文件查找完毕并记录在fileList.txt中 !
echo 现查到%b%文件总的个数:!n!
start fileList.txt

可以对打开的全部文件进行批量查找和替换:

可以直接设置编码格式:

-End-

最近发表
标签列表