-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathturn-on-echo.bat
30 lines (24 loc) · 1.82 KB
/
turn-on-echo.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
::=================================================
:: Turn on echo to debug and locate problems.
:: Basically, Replace "echo off" to "echo on":
:: msr -rp directory1,file1 -f "\.(bat|cmd)$" -it "^(\s*@\s*echo)\s+off\b" -o "$1 on" -R
::=================================================
@if "%PATH:~-1%" == "\" set "PATH=%PATH:~0,-1%"
@echo off
SetLocal EnableExtensions EnableDelayedExpansion
where msr.exe 2>nul >nul || if not exist %~dp0\msr.exe powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri https://github.com/qualiu/msr/blob/master/tools/msr.exe?raw=true -OutFile %~dp0\msr.exe"
where msr.exe 2>nul >nul || set "PATH=%PATH%;%~dp0"
@if "%~1" == "" (
echo Usage : %~n0 Files_Directories [msr_Options: Optional] | msr -aPA -e "%~n0\s+(\S+).*"
echo Example: %~n0 "directory1,file1,file2" | msr -aPA -e "%~n0\s+(\S+).*"
echo Example: %~n0 "directory1,file1,file2" -R | msr -aPA -e "%~n0\s+(\S+).*"
echo Example: %~n0 "directory1,file1,file2" -r | msr -aPA -e "%~n0\s+(\S+).*"
echo Example: %~n0 "directory1,file1,file2" -r -R | msr -aPA -e "%~n0\s+(\S+).*"
echo Example: %~n0 "directory1,file1,file2" --nd "^(softwares|logs|data|target|bin|obj|Debug|Release)$" -r -R | msr -aPA -e "%~n0\s+(\S+).*"
echo Use -r to recursively search or replace; Use -R to replace, preview without -R. | msr -aPA -t "-\w\b" -e .+
echo Should not use -p as occuppied. | msr -PA -t "-\S+|(\w+)"
echo It just calls: msr -rp directory1,file1 -f "\.(bat|cmd)$" -it "^(\s*@\s*echo)\s+off\b" -o "$1 on" -R | msr -aPA -e "msr (-rp \S+).*" -t "\s+-[rp]+\s+|\s+(-\w+)\s+"
exit /b -1
)
:: first argument must be the path, just like above examples.
msr -f "\.(bat|cmd)$" -it "^(\s*@\s*echo)\s+off\b" -o "$1 on" -p %*