本帖最后由 flashercs 于 2019-9-3 22:26 编辑
保存为a.bat,右键以管理员身份运行- @echo off
- REM 设置脚本保存路径
- set "batfile=E:\test\New folder\zuma\一键改.bat"
- for /f "tokens=1 delims=:" %%A in ('findstr /ben "####*" %0') do (
- >"%batfile%",more +%%A %0
- )
- reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\mycmd" /ve /t REG_SZ /d "一键改" /f
- reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\mycmd" /v "Icon" /t REG_EXPAND_SZ /d "\"%windir%\system32\cmd.exe\",0" /f
- reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\mycmd\command" /ve /t REG_SZ /d "\"%batfile%\" \"%%V\"" /f
- pause
- exit /b
- ################################################
- 0<1/*,:
- @echo off
- set str2search="A10"
- cd /d "%~1"
- set /p dirprefix=请输入替换字符:
- for %%A in ("..\%dirprefix%%~nx1") do set "dstdir=%%~fA"
- REM md "%dstdir%"
- dir /a-d /b|findstr /elv ".xls .xlsx .jpg .png .gif .bmp"|findstr /limc:%str2search% /f:/|Cscript.exe -nologo -e:jscript %0 "%~1" "%dstdir%" %str2search% "%dirprefix%"
-
- exit /b
- */
- var fso = WSH.CreateObject('Scripting.FileSystemObject');
- var wshell = WSH.CreateObject('WScript.Shell');
- var currdir = wshell.CurrentDirectory = WSH.Arguments(0);
- var dstdir = WSH.Arguments(1);
- var str2search = WSH.Arguments(2);
- var str2replace = WSH.Arguments(3);
- if (!fso.FolderExists(dstdir)) {
- fso.CreateFolder(dstdir);
- }
- while (!WSH.StdIn.AtEndOfStream) {
- var filename = WSH.StdIn.ReadLine();
- try {
- var tsread = fso.OpenTextFile(filename, 1, false, -2);
- var tswrite = fso.OpenTextFile(fso.BuildPath(dstdir, str2replace + filename), 2, true, -2);
- while (!tsread.AtEndOfStream) {
- tswrite.Write(tsread.ReadAll().replace(RegExp(reEscape(str2search), 'g'), function(){return str2replace;}));
- }
- } catch (e) {
-
- } finally {
- if (tsread) {
- tsread.close();
- }
- if (tswrite) {
- tswrite.close();
- }
- }
- }
-
- function reEscape(str) {
- return str.replace(/[\\^$[(){?*+|.]/g, '\\$&');
- }
复制代码
|