I am inside a directory which contains two directories - "games" and "music" and I want to descend into either "games" or "music" depending on which one has a bigger size.
1 Answer
Way 1:
commandline:
powershell $w1='D:\games';$w2='D:\music';$s1=(ls -Re -Fo $w1^|Measure -pr length -s).sum;$s2=(ls -Re -Fo $w2^|Measure -pr length -s).sum;if($s1 -gt $s2){explorer $w1}else{explorer $w2}
Way 2:
MaxCD.cmd:
@ECHO OFF
SET W1=D:\games
SET W2=D:\music
powershell $w1='%W1%';$w2='%W2%';$s1=(ls -Re -Fo $w1^|Measure -pr length -s).sum;$s2=(ls -Re -Fo $w2^|Measure -pr length -s).sum;echo $s1' '$w1 $s2' '$w2`n;if($s1 -gt $s2){exit 11}else{exit 12}
ECHO ERRORLEVEL: %ERRORLEVEL%
IF "%ERRORLEVEL%" EQU "11" CD /D "%W1%"
IF "%ERRORLEVEL%" EQU "12" CD /D "%W2%"
ECHO.
ECHO Jump directory: %CD%