-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from frank-e/2019
2019
- Loading branch information
Showing
12 changed files
with
752 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
@echo off & @rem based on XNT.kex script template version 2016-03-05 | ||
setlocal enableextensions & prompt @ | ||
if not "%~2" == "" call "%~0" "%*" | ||
if not "%~2" == "" goto DONE & @rem expect one argument | ||
if "%~1" == "" goto HELP & @rem expect one argument | ||
if "%~1" == "?" goto HELP & @rem missing switch char | ||
if "%~1" == "/?" goto HELP & @rem minimal requirement | ||
if "%~1" == "-?" goto HELP & @rem permit DOS SWITCHAR | ||
if exist "%~1\*" goto HELP & @rem bypass subdirectory | ||
:DOIT -------------------------------------------------------------- | ||
set NEED=%~1 | ||
if not exist "%NEED%" goto NEED | ||
set NEED=sha1sum.exe | ||
for %%x in ("%NEED%") do if not exist "%%~f$PATH:x" goto NEED | ||
set HASH=%NEED% "%~1" | ||
set NEED=win32 | ||
rem delims=\ to get rid of odd leading backslash in sha256sum output | ||
for /F "tokens=1 usebackq delims=\ " %%x in (`%HASH%`) do set NEED=%%x | ||
if "%NEED%" == "win32" goto FAIL | ||
set NEED=https://tineye.com/search/%NEED% | ||
echo start %NEED% | ||
start %NEED% | ||
if errorlevel 1 goto NEED | ||
set NEED=timeout.exe | ||
for %%x in ("%NEED%") do if not exist "%%~f$PATH:x" goto WAIT | ||
%NEED% /T 10 | ||
goto DONE | ||
:FAIL -------------------------------------------------------------- | ||
rem 32bit sha256sum cannot "see" all system32 files on 64bit windows | ||
echo %HASH% | ||
%HASH% | ||
echo Error: %0 got non-zero exit code [%ERRORLEVEL%] | ||
goto WAIT | ||
:NEED -------------------------------------------------------------- | ||
echo/ | ||
echo Error: %0 found no "%NEED%" | ||
:HELP -------------------------------------------------------------- | ||
echo Usage: %0 FILE | ||
echo/ | ||
echo Requires sha1sum.exe in the path to open | ||
echo https://tineye.com/search/hash-of-FILE | ||
echo Maybe create a shell:sendto shortcut to %~nx0. | ||
echo/ | ||
:WAIT if first CMD line option was /c ------------------------------ | ||
set NEED=usebackq tokens=2 delims=/ | ||
for /F "%NEED% " %%c in ('%CMDCMDLINE%') do if /I "%%c" == "c" pause | ||
:DONE -------------- (Frank Ellermann, 2016) ----------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
@echo off & @rem based on XNT.kex script template version 2016-03-05 | ||
setlocal enableextensions & prompt @ | ||
if not "%~2" == "" call "%~0" "%*" | ||
if not "%~2" == "" goto DONE & @rem expect one argument | ||
if "%~1" == "" goto HELP & @rem expect one argument | ||
if "%~1" == "?" goto HELP & @rem missing switch char | ||
if "%~1" == "/?" goto HELP & @rem minimal requirement | ||
if "%~1" == "-?" goto HELP & @rem permit DOS SWITCHAR | ||
if exist "%~1\*" goto HELP & @rem bypass subdirectory | ||
:DOIT -------------------------------------------------------------- | ||
set NEED=%~1 | ||
if not exist "%NEED%" goto NEED | ||
set NEED=sha256sum.exe | ||
for %%x in ("%NEED%") do if not exist "%%~f$PATH:x" goto NEED | ||
set HASH=%NEED% "%~1" | ||
set NEED=win32 | ||
rem delims=\ to get rid of odd leading backslash in sha256sum output | ||
for /F "tokens=1 usebackq delims=\ " %%x in (`%HASH%`) do set NEED=%%x | ||
if "%NEED%" == "win32" goto FAIL | ||
set NEED=https://www.virustotal.com/latest-scan/%NEED% | ||
echo start %NEED% | ||
start %NEED% | ||
if errorlevel 1 goto NEED | ||
set NEED=timeout.exe | ||
for %%x in ("%NEED%") do if not exist "%%~f$PATH:x" goto WAIT | ||
%NEED% /T 10 | ||
goto DONE | ||
:FAIL -------------------------------------------------------------- | ||
rem 32bit sha256sum cannot "see" all system32 files on 64bit windows | ||
echo %HASH% | ||
%HASH% | ||
echo Error: %0 got non-zero exit code [%ERRORLEVEL%] | ||
goto WAIT | ||
:NEED -------------------------------------------------------------- | ||
echo/ | ||
echo Error: %0 found no "%NEED%" | ||
:HELP -------------------------------------------------------------- | ||
echo Usage: %0 FILE | ||
echo/ | ||
echo Requires sha256sum.exe in the path to open | ||
echo https://www.virustotal.com/latest-scan/hash_of_FILE | ||
echo Maybe create a shell:sendto shortcut to %~nx0. | ||
echo/ | ||
:WAIT if first CMD line option was /c ------------------------------ | ||
set NEED=usebackq tokens=2 delims=/ | ||
for /F "%NEED% " %%c in ('%CMDCMDLINE%') do if /I "%%c" == "c" pause | ||
:DONE -------------- (Frank Ellermann, 2016) ----------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@echo off & @rem based on XNT.kex script template version 2016-03-05 | ||
setlocal enableextensions & prompt @ | ||
if not "%~2" == "" call "%~0" "%*" | ||
if not "%~2" == "" goto DONE & @rem expect one argument | ||
if "%~1" == "" goto TEMP & @rem expect one argument | ||
if "%~1" == "?" goto HELP & @rem missing switch char | ||
if "%~1" == "/?" goto HELP & @rem minimal requirement | ||
if "%~1" == "-?" goto HELP & @rem permit DOS SWITCHAR | ||
:DOIT -------------------------------------------------------------- | ||
set NEED=%~f1 | ||
if not exist "%NEED%" goto NEED | ||
if exist "%~f1\*" cd /D "%~f1\." | ||
if exist "%~f1\*" goto OKAY & @rem valid directory | ||
if exist "%~f1\.." cd /D "%~f1\.." | ||
if exist "%~f1\.." goto OKAY & @rem valid parent | ||
goto NEED | ||
:TEMP -------------------------------------------------------------- | ||
if /I "%CD%" == "%SystemRoot%\System32" cd /D "%TEMP%" | ||
:OKAY -------------------------------------------------------------- | ||
endlocal & cd /D "%CD%" | ||
goto DONE | ||
:NEED -------------------------------------------------------------- | ||
echo/ | ||
echo Error: %0 found no "%NEED%" | ||
:HELP -------------------------------------------------------------- | ||
echo Usage: %0 FILE | ||
echo/ | ||
echo Switches the current directory to the path of the specified | ||
echo existing FILE or directory. Wildcards (* or ?) are allowed. | ||
echo/ | ||
echo Maybe create a shell::sendto shortcut (link) for | ||
echo %%COMSPEC%% /k %~dpnx0 | ||
echo/ | ||
:WAIT if first CMD line option was /c ------------------------------ | ||
set NEED=usebackq tokens=2 delims=/ | ||
for /F "%NEED% " %%c in ('%CMDCMDLINE%') do if /I "%%c" == "c" pause | ||
:DONE -------------- (Frank Ellermann, 2016) ----------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@echo off & @rem based on XNT.kex script template version 2016-03-05 | ||
setlocal enableextensions & prompt @ | ||
if not "%~2" == "" call "%~0" "%*" | ||
if not "%~2" == "" goto DONE & @rem expect one argument | ||
if "%~1" == "" goto HELP & @rem expect one argument | ||
if "%~1" == "?" goto HELP & @rem missing switch char | ||
if "%~1" == "/?" goto HELP & @rem minimal requirement | ||
if "%~1" == "-?" goto HELP & @rem permit DOS SWITCHAR | ||
:DOIT -------------------------------------------------------------- | ||
set NEED=clip.exe | ||
for %%x in (%NEED%) do if not exist "%%~f$PATH:x" goto NEED | ||
set NEED=%~1 | ||
if not exist "%NEED%" goto NEED | ||
echo echo %~f1^|clip.exe | ||
call echo %~f1|clip.exe | ||
if not errorlevel 1 goto DONE | ||
echo Error: %0 got exit code [%ErrorLevel%] | ||
goto WAIT | ||
:NEED -------------------------------------------------------------- | ||
echo/ | ||
echo Error: %0 found no "%NEED%" | ||
:HELP -------------------------------------------------------------- | ||
echo Usage: %0 PATH | ||
echo/ | ||
echo Puts the full path of the given existing PATH into the | ||
echo clipboard with the first found CLIP.EXE, for use in a | ||
echo shell:sendto link. | ||
echo/ | ||
:WAIT if first CMD line option was /c ------------------------------ | ||
set NEED=usebackq tokens=2 delims=/ | ||
for /F "%NEED% " %%c in ('%CMDCMDLINE%') do if /I "%%c" == "c" pause | ||
:DONE -------------- (Frank Ellermann, 2016) ----------------------- | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
@echo off & @rem based on XNT.kex script template version 2016-03-05 | ||
setlocal enableextensions & prompt @ | ||
if not "%~3" == "" call "%~0" "%*" | ||
if not "%~3" == "" goto DONE & @rem up to two arguments | ||
if "%~1" == "" goto HELP & @rem expect one argument | ||
if "%~1" == "?" goto HELP & @rem missing switch char | ||
if "%~1" == "/?" goto HELP & @rem minimal requirement | ||
if "%~1" == "-?" goto HELP & @rem permit DOS SWITCHAR | ||
:DOIT -------------------------------------------------------------- | ||
if not exist "%~1\*" set LINK=/H | ||
if exist "%~1\*" set LINK=/D | ||
set NEED=%~f1 | ||
if not exist "%NEED%" goto NEED | ||
if "%~2" == "" goto WHAT | ||
set DEST=%~2 | ||
if not exist "%DEST%" goto GOOD | ||
if exist "%~2\*" set DEST=%~dp2%~nx1 | ||
if not exist "%DEST%" goto GOOD | ||
if exist "%DEST%" goto DEST | ||
:WHAT -------------------------------------------------------------- | ||
pushd "%~dp1." | ||
echo SRC=%NEED% | ||
echo CWD=%CD% | ||
set /P DEST=DST= | ||
for /F "usebackq tokens=*" %%x in ('%DEST%') do set DEST=%%~fx | ||
popd | ||
if "%DEST%" == "" goto UTIL | ||
if exist "%DEST%\*" set DEST=%DEST%\%~nx1 | ||
if exist "%DEST%" goto DEST | ||
:GOOD -------------------------------------------------------------- | ||
echo mklink %LINK% "%DEST%" "%NEED%" | ||
mklink %LINK% "%DEST%" "%NEED%" | ||
if errorlevel 1 goto DEST | ||
if "%LINK%" == "/D" goto WAIT | ||
:UTIL -------------------------------------------------------------- | ||
set NEED=fsutil.exe | ||
for %%x in (%NEED%) do if not exist "%%~f$PATH:x" goto NEED | ||
echo/ | ||
echo %NEED% hardlink list "%~1" | ||
%NEED% hardlink list "%~1" | ||
echo/ | ||
goto WAIT | ||
:DEST -------------------------------------------------------------- | ||
echo/ | ||
echo Error: %0 cannot create "%DEST%" | ||
goto HELP | ||
:NEED -------------------------------------------------------------- | ||
echo/ | ||
echo Error: %0 found no "%NEED%" | ||
:HELP -------------------------------------------------------------- | ||
echo Usage: %0 FILE [DEST] | ||
echo/ | ||
echo Shorthand for "mklink /H", determines a missing DEST | ||
echo interactively, suited for a simple shell:sendto link. | ||
echo DEST can be a directory to keep the name of the FILE | ||
echo as is. | ||
echo/ | ||
:WAIT -------------------------------------------------------------- | ||
set NEED=usebackq tokens=2 delims=/ | ||
for /F "%NEED% " %%c in ('%CMDCMDLINE%') do if /I "%%c" == "c" pause | ||
:DONE -------------- (Frank Ellermann, 2016) ----------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
@echo off & @rem based on XNT.kex script template version 2016-03-05 | ||
setlocal enableextensions & prompt @ | ||
if not "%~2" == "" call "%~0" "%*" | ||
if not "%~2" == "" goto DONE & @rem expect one argument | ||
if "%~1" == "" goto HELP & @rem expect one argument | ||
if "%~1" == "?" goto HELP & @rem missing switch char | ||
if "%~1" == "/?" goto HELP & @rem minimal requirement | ||
if "%~1" == "-?" goto HELP & @rem permit DOS SWITCHAR | ||
:DOIT -------------------------------------------------------------- | ||
set NEED=%~1 | ||
set FILE=%~1 | ||
set DEST=%~n1.zip | ||
set WORK=nul | ||
set OPTS=-tzip -mx=9 -mfb=255 -mmt=off -mpass=15 -- | ||
if not exist "%NEED%" goto NEED | ||
::: PROG=7z.exe or 7za.exe in %ProgramFiles%\7-ZIP or %PATH% | ||
set NEED=7z.exe 7za.exe | ||
set PROG=%ProgramFiles%\7-ZIP;%PATH% | ||
for %%x in (%NEED%) do if exist "%%~f$PROG:x" set PROG=%%~f$PROG:x | ||
if not exist "%PROG%" goto NEED | ||
if exist "%~1\*" goto PDIR | ||
"%PROG%" t -- "%FILE%">nul | ||
if errorlevel 1 goto FAIL | ||
if not "%TEMP%" == "" set TMP=%TEMP% | ||
if not exist "%TMP%\*" set TMP=. | ||
set DEST=%TMP%\%~n1 | ||
set WORK=%DEST% | ||
if exist "%DEST%\*" rmdir /S "%DEST%" | ||
if exist "%DEST%\*" goto DEST | ||
if exist "%DEST%" erase /P "%DEST%" | ||
if exist "%DEST%" goto DEST | ||
set DEST=%~n1.bak | ||
if exist "%DEST%\*" rmdir /S "%DEST%" | ||
if exist "%DEST%\*" goto DEST | ||
if exist "%DEST%" erase /P "%DEST%" | ||
if exist "%DEST%" goto DEST | ||
set DEST=%~n1.zip | ||
"%PROG%" x -o"%WORK%" -- "%~1" | ||
if errorlevel 1 goto FAIL | ||
set NEED=%WORK% | ||
dir /B "%WORK%"|find /I /V "%~n1">nul | ||
if not errorlevel 1 goto PACK & @rem not only %~n1 stuff | ||
dir /B "%WORK%"|find /I /C "%~n1"|find "1">nul | ||
if errorlevel 1 goto PACK & @rem not exactly 1 thing | ||
set NEED=%WORK%\%~n1 | ||
if exist "%NEED%\*" goto PACK & @rem only 1 subdirectory | ||
set NEED=%WORK%\%~n1.tar | ||
if not exist "%NEED%" goto PACK & @rem this is no %~n1.tar | ||
set NEED=%WORK%\%~n1 | ||
"%PROG%" x -o"%NEED%" -- "%NEED%.tar" | ||
if errorlevel 1 goto FAIL | ||
:PACK -------------------------------------------------------------- | ||
if not exist "%NEED%" set NEED=%WORK% | ||
if exist "%DEST%" set FILE=%~dpn1.bak | ||
if exist "%DEST%" ren "%DEST%" "%~n1.bak" | ||
if exist "%DEST%" goto FAIL | ||
"%PROG%" a %OPTS% "%DEST%" "%NEED%" | ||
if errorlevel 1 goto FAIL | ||
echo Ready: %0 created "%DEST%" | ||
for %%x in ("%FILE%") do echo %%~tznxx | ||
for %%x in ("%DEST%") do echo %%~tznxx | ||
del /P "%FILE%" | ||
rmdir /S /Q "%WORK%" | ||
goto DONE | ||
:PDIR -------------------------------------------------------------- | ||
if exist "%DEST%" goto DEST | ||
"%PROG%" a %OPTS% "%DEST%" "%~1" | ||
if errorlevel 1 goto FAIL | ||
echo Ready: %0 created "%DEST%" | ||
for %%x in ("%DEST%") do echo %%~tznxx | ||
goto WAIT | ||
:FAIL -------------------------------------------------------------- | ||
echo/ | ||
if errorlevel 1 echo Error: %0 got exit code [%ERRORLEVEL%] | ||
if exist "%WORK%\*" rmdir /S /Q "%WORK%" | ||
goto WAIT | ||
:DEST -------------------------------------------------------------- | ||
echo/ | ||
echo Error: %0 cannot create "%DEST%" | ||
goto WAIT | ||
:NEED -------------------------------------------------------------- | ||
echo/ | ||
echo Error: %0 found no "%NEED%" | ||
:HELP -------------------------------------------------------------- | ||
echo Usage: %0 NAME.EXT | ||
echo/ | ||
echo 1: Use 7z.exe or 7za.exe in %%ProgramFiles%%\7-ZIP or %%PATH%%. | ||
echo 2: If NAME.EXT is a directory pack it into NAME.zip and exit. | ||
echo Otherwise test it with 7-ZIP and exit on error. | ||
echo 3: Get rid of any old %%TEMP%%\NAME (and NAME.bak for step 6). | ||
echo 4: Extract NAME.EXT into %%TEMP%%\NAME. | ||
echo 5: If only %%TEMP%%\NAME\NAME exists goto 6 using NAME\NAME. | ||
echo If only %%TEMP%%\NAME\NAME.tar exists extract it into | ||
echo %%TEMP%%\NAME\NAME and goto 6 using NAME\NAME. | ||
echo 6: If target .\NAME.zip is the same as source NAME.EXT rename | ||
echo the source to NAME.bak. Undo on error not yet implemented. | ||
echo 7: Pack %%TEMP%%\NAME (or NAME\NAME) in .\NAME.zip and remove | ||
echo %%TEMP%%\NAME. Offer to delete NAME.EXT (or bak), and exit. | ||
echo/ | ||
:WAIT if first CMD line option was /c ------------------------------ | ||
set NEED=usebackq tokens=2 delims=/ | ||
for /F "%NEED% " %%c in ('%CMDCMDLINE%') do if /I "%%c" == "c" pause | ||
:DONE -------------- (Frank Ellermann, 2016) ----------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
@echo off & @rem based on XNT.kex script template version 2016-03-05 | ||
setlocal enableextensions & prompt @ | ||
if not "%~3" == "" call "%~0" "%*" | ||
if not "%~3" == "" goto DONE & @rem up to two arguments | ||
if "%~1" == "" goto HELP | ||
if "%~1" == "?" goto HELP & @rem missing switch char | ||
if "%~1" == "/?" goto HELP & @rem minimal requirement | ||
if "%~1" == "-?" goto HELP & @rem permit DOS SWITCHAR | ||
if exist "%~1\*" goto HELP & @rem bypass subdirectory | ||
:DOIT -------------------------------------------------------------- | ||
set NEED=%ProgramFiles%\Perforce\p4merge.exe | ||
if not exist "%NEED%" goto NEED | ||
set EXEC=start "%~0" /D . "%NEED%" | ||
set NEED=%~f1 | ||
if not exist "%NEED%" goto NEED | ||
if "%~2" == "" goto WHAT | ||
set NEED=%~2 | ||
set DEST=%~2 | ||
if /I "%~f1" == "%~f2" goto DEST | ||
if not exist "%DEST%" goto DEST | ||
if exist "%DEST%" goto GOOD | ||
:WHAT -------------------------------------------------------------- | ||
pushd "%~dp1." | ||
echo SRC=%NEED% | ||
echo CWD=%CD% | ||
set /P DEST=DST= | ||
for /F "usebackq tokens=*" %%x in ('%DEST%') do set DEST=%%~fx | ||
popd | ||
if exist "%DEST%" goto GOOD | ||
set NEED=%DEST% | ||
if not "%NEED%" == "" goto NEED | ||
if "%NEED%" == "" goto HELP | ||
:GOOD -------------------------------------------------------------- | ||
echo %EXEC% "%~f1" "%DEST%" | ||
%EXEC% "%~f1" "%DEST%" | ||
if not errorlevel 1 goto DONE | ||
goto WAIT | ||
:DEST -------------------------------------------------------------- | ||
echo/ | ||
echo Error: %0 cannot create "%DEST%" | ||
goto HELP | ||
:NEED -------------------------------------------------------------- | ||
echo/ | ||
echo Error: %0 found no "%NEED%" | ||
:HELP -------------------------------------------------------------- | ||
echo Usage: %0 FILE1 [FILE2] | ||
echo/ | ||
echo If both paths are given and exist the script starts comparison | ||
echo with %ProgramFiles%\Perforce\P4merge.exe | ||
echo If FILE2 is not given in can be specified manually as relative | ||
echo PATH2 from the directory of the first file. The file name and | ||
echo extension in PATH2 can be omitted if they match PATH1. | ||
echo/ | ||
:WAIT if first CMD line option was /c ------------------------------ | ||
set NEED=usebackq tokens=2 delims=/ | ||
for /F "%NEED% " %%c in ('%CMDCMDLINE%') do if /I "%%c" == "c" pause | ||
:DONE -------------- (Frank Ellermann, 2016) ----------------------- |
Oops, something went wrong.