@echo off
REM для https://qna.habr.com/q/1027240
set C=%~nx0
if NOT "%DEBUG%" equ "" echo Running with DEBUG set
REM using two environment parameters: C and DEBUG
REM NOTE: passing arguments appears tricky when
REM powershell run with command built inline as string
@powershell.exe -ExecutionPolicy Bypass -Command "$debug=$env:DEBUG;$s=(get-content \"%~f0\") -join \"`n\"; $s = $s.substring($s.IndexOf(\"goto :\"+\"EOF\")+9);if ($debug -ne $null){write-output (\"Running:`n{0}\" -f$s);} invoke-expression -command $s"
@goto :EOF
# powershell code
start-sleep 5
write-output ( 'Calling script: {0}' -f $env:C)
pause
exit 0
c:\Users\sergueik\Desktop>set debug=1
c:\Users\sergueik\Desktop>show_caller.cmd
Running with DEBUG set
Running:
Start-Sleep 5
write-output ( 'Calling script: {0}' -f $env:C)
pause
exit 0
Calling script: show_caller.cmd
Press Enter to continue...:
check.cmd
@echo OFF
REM https://qna.habr.com/q/898855
SETLOCAL ENABLEDELAYEDEXPANSION
SET delta=%1
IF "%delta%"=="" SET delta=-3
FOR /f %%. IN ('cscript.exe /nologo add_days.js !delta!') DO SET CHECK_DATE=%%.
ECHO FORFILES /p . /s /m *.* /d !CHECK_DATE! /c "cmd /c echo @FILE"
FORFILES /p . /s /m *.* /d !CHECK_DATE! /c "cmd /c echo @FILE" 2>NUL 1>NUL
IF errorlevel 1 ECHO Skip Purge && GOTO :EOF
echo Call purge
GOTO :EOF
add_date.js
var days=parseInt(WScript.Arguments.Item(0));
Date.prototype.addDays = function(days) { var date = new Date(this.valueOf()); date.setDate(date.getDate() + days); return date; }
var o = (new Date()).addDays(days);
WScript.Echo((1 + o.getMonth()) + '/' + o.getDate() + '/' + o.getFullYear());
dir
Directory of C:\Users\Serguei\AppData\Local\Temp\xxx
11/18/2020 09:46 AM <DIR> .
11/18/2020 09:46 AM <DIR> ..
11/18/2020 09:46 AM 0 BCJ-042102_1.jpg
11/18/2020 09:46 AM 0 BCJ-042102_2.jpg
11/18/2020 09:46 AM 0 BCJ-042102_3.jpg
11/18/2020 09:46 AM 0 BLN-021301_2.jpg
11/18/2020 09:46 AM 0 BLN-021301_3.jpg
11/18/2020 09:46 AM 0 DZPB-049001_1.jpg
11/18/2020 09:46 AM 0 DZPB-049001_2.jpg
11/18/2020 09:46 AM 0 DZPB-049001_4.jpg
8 File(s) 0 bytes
for /F %. in ('dir /b *.*') ; do mkdir %~n. && move /y %. %~n.
dir
Directory of C:\Users\Serguei\AppData\Local\Temp\xxx
1/18/2020 09:47 AM <DIR> .
1/18/2020 09:47 AM <DIR> ..
1/18/2020 09:47 AM <DIR> BCJ-042102_1
1/18/2020 09:47 AM <DIR> BCJ-042102_2
1/18/2020 09:47 AM <DIR> BCJ-042102_3
1/18/2020 09:47 AM <DIR> BLN-021301_2
1/18/2020 09:47 AM <DIR> BLN-021301_3
1/18/2020 09:47 AM <DIR> DZPB-049001_1
1/18/2020 09:47 AM <DIR> DZPB-049001_2
1/18/2020 09:47 AM <DIR> DZPB-049001_4
0 File(s) 0 bytes
C:\Users\Serguei\AppData\Local\Temp\xxx\BCJ-042102_1\BCJ-042102_1.jpg
C:\Users\Serguei\AppData\Local\Temp\xxx\BCJ-042102_2\BCJ-042102_2.jpg
C:\Users\Serguei\AppData\Local\Temp\xxx\BCJ-042102_3\BCJ-042102_3.jpg
C:\Users\Serguei\AppData\Local\Temp\xxx\BLN-021301_2\BLN-021301_2.jpg
C:\Users\Serguei\AppData\Local\Temp\xxx\BLN-021301_3\BLN-021301_3.jpg
C:\Users\Serguei\AppData\Local\Temp\xxx\DZPB-049001_1\DZPB-049001_1.jpg
C:\Users\Serguei\AppData\Local\Temp\xxx\DZPB-049001_2\DZPB-049001_2.jpg
C:\Users\Serguei\AppData\Local\Temp\xxx\DZPB-049001_4\DZPB-049001_4.jpg
Usage:
windiff [options] path1 [path2]
Options:
-D Compare one directory only.
-F[flags] savefile Save composite file to 'savefile'.
The 'flags' may consist of one or more of I (identical), L (left), R (right), F (moved leFt),
G (moved riGht), S (Similar left), A (similiAr right), X (exit after saving list).
(e.g. -FLF saves list of Left or moved-leFt lines).
WinDiff.Exe /FRLIX diff.txt a.txt b.txt
jq
то повершел convertfrom-json
$a = @'
{
"Login": "Alex" ,
"Password": "qwerty" ,
"Domain": "Alex" ,
"Output_json": "json_files" ,
"Output_log": "logs"
}
'@
$a | convertfrom-json
Login : Alex
Password : qwerty
Domain : Alex
Output_json : json_files
Output_log : logs
set foldername=%%a
md %Src%\%foldername%
set foldername=%%a
md %Src%\!foldername!
SETLOCAL ENABLEDELAYEDEXPANSION