Sum the file sizes on Linux

find ./test -type f -name '*.jpg' -exec du -cb {} + | grep total$

Windows batch scripting notes

  • pass all arguments:
    java -jar app.jar %*
  • logical AND in IF conditionals
    IF %age% geq 18 (
        IF %age% leq 68 (
            SET class=working
    IF %age% geq 0 IF %age% leq 18 SET class=children
  • logical OR in IF conditionals
    SET children_or_elderly=F
    IF %age% leq 18 set children_or_elderly=T
    IF %age% geq 60 set children_or_elderly=T
    IF "%children_or_elderly%"=="T" (
        ECHO kids or retired
  • Test if the argument exists
    IF [%1] == [] ECHO No arguments
  • Count number of arguments
    SET nbArgs=0
    FOR %%x IN (%*) DO SET /A nbArgs+=1
    ECHO %nbArgs%
  • Check if file exists
    IF NOT EXIST C:\FILE2.TXT ECHO not exist

see also

Sort LinkedHashMap by key or by value in Java 8