CMD NewLine Character

set NEWLINE=^& echo.
echo hello%NEWLINE%world

And You’ll get

Hello
World

FFMPEG – High-Interest Video Thumbnails

  • ffmpeg is capable of measuring the difference between every scene,
    and you may specify you want the difference to be above/below some rate to include that thumbnail.
  • black/white/uni-color screens are common as a transition, and are not a “problem”, we should generate quite a lot of thumbnails, and storing them as JPG (loosely format), which has very high compression rate for uni-color images, web can sort the images by size (later) and just remove that below 1kb images.
  • the same issue can also be addressed by performing quite large jumps into the movie, which in-turn also generate a more story-line variety.
  • Just Good Business:
    – Keeping thumbnails small enough, undistorted (in ratio) can be easily achieved by limiting the width to 200 pixels, together with height-ratio matching and smart-cropping, this way, in-image is mostly undisrupted, cropped without missing important-ingredient and provide unified size.
    – zero-padded output file name can help with sorting on older systems that might sort 10.jpg right after 1.jpg in normal cases (Windows XP/NT and below).
ffmpeg -ss 100 -i my_movie.mp4 -vf "select=gt(scene\,0.1)" -frames:v 50 -filter:v scale=200:-1,crop=iw:ih*0.8,fps=1/10 out%04d.jpg

for example this ~4minutes YouTube Video:

Continue reading

CMD Ninja – Relative To Fully Qualified Path And Other File Properties Without Directing Relative Path To Another CMD-File As An Argument

Given the following directory-tree
icompile.eladkarako.com_cmd_file_path_properties_short_relative_file_name_directory_folder_without_sending_to_another_cmd_file_as_argument_args

I want to get some information on apktool_2.0.2.jar
for example fully-qualified short (old dos 8.3 format that is compatible with old Java argument’ing) path,

here is a snippet containing it,
this ‘_’ prefix is advisable, the double ‘%’ is to escape the loop’s variable, the ‘~’ is to strip any \’ \” wrapping chars around the path (best practice, always use it), the reason ‘_drive’ phrase has (also) ‘s’ in it is to make the result more letter-case consistent (the 8.3 format uses Upper-Case while if you’ll run CMD console and browse or change-dir using a Lower-Case drive letter it will be embodied in the result).

@echo off
set relative=.\apktool_2.0.2.jar

for /f %%a in ("%relative%")do (set "_full=%%~fa"     )
for /f %%a in ("%relative%")do (set "_full83=%%~fsa"  )
for /f %%a in ("%relative%")do (set "_drive=%%~dsa"   )
for /f %%a in ("%relative%")do (set "_path=%%~pa"     )
for /f %%a in ("%relative%")do (set "_path83=%%~psa"  )
for /f %%a in ("%relative%")do (set "_name=%%~na"     )
for /f %%a in ("%relative%")do (set "_name83=%%~nsa"  )
for /f %%a in ("%relative%")do (set "_ext=%%~xa"      )
for /f %%a in ("%relative%")do (set "_ext83=%%~xsa"   )
for /f %%a in ("%relative%")do (set "_att=%%~aa"      )
for /f %%a in ("%relative%")do (set "_time=%%~ta"     )
for /f %%a in ("%relative%")do (set "_size=%%~za"     )

echo %_full%
echo %_full83%
echo %_drive%
echo %_path%
echo %_path83%
echo %_name%
echo %_name83%
echo %_ext%
echo %_ext83%
echo %_att%
echo %_time%
echo %_size%

::------------------------------------------------------------::
::  relative  < ->  .\apktool_2.0.2.jar                        ::
::------------------------------------------------------------::
::  _full     < ->  D:\DOS\android\bin\apktool_2.0.2.jar       ::
::  _full83   < ->  D:\DOS\android\bin\APKTOO~1.JAR            ::
::  _drive    < ->  D:                                         ::
::  _path     < ->  \DOS\android\bin\                          ::
::  _path83   < ->  \DOS\android\bin\                          ::
::  _name     < ->  apktool_2.0.2                              ::
::  _name83   < ->  APKTOO~1                                   ::
::  _ext      < ->  .jar                                       ::
::  _ext83    < ->  .JAR                                       ::
::  _att      < ->  --a------                                  ::
::  _time     < ->  10/14/2015 02:06 PM                        ::
::  _size     < ->  6329931                                    ::
::------------------------------------------------------------::

CMD Ninja – Unlimited Arguments Processing, Identifying If Exist In File-System, Identifying If File Or Directory

@echo off

:loop
      ::-------------------------- has argument ?
      if ["%~1"]==[""] (
        echo done.
        goto end
      )
      ::-------------------------- argument exist ?
      if not exist %~s1 (
        echo not exist
      ) else (
        echo exist
        if exist %~s1\NUL (
          echo is a directory
        ) else (
          echo is a file
        )
      )
      ::--------------------------
      shift
      goto loop
      
      
:end

pause

save it as identifier.cmd
it can identify an unlimited arguments (normally you are limited to %1%9), just remember to wrap the arguments with inverted-commas, or use 8.3 naming, or drag&drop them over (it automatically does either of above).

this allows you to run the following commands:
identifier.cmd c:\windows
and to get

exist
is a directory
done

identifier.cmd "c:\Program Files (x86)\Microsoft Office\OFFICE11\WINWORD.EXE"
and to get

exist
is a file
done

and multiple arguments (of course this is the whole-deal..)
identifier.cmd c:\windows\system32 c:\hiberfil.sys "c:\pagefile.sys" hello-world
and to get

exist
is a directory
exist
is a file
exist
is a file
not exist
done.

naturally it can be a lot more complex,
but nice examples should be simple and minimal.

also posted at StackOverflow:

Chromium Installer – Download Latest Nightly-Build Snapshot

figured it out.

1.
get latest revision number from this url: http://commondatastorage.googleapis.com/chromium-browser-continuous/Win/LAST_CHANGE

2.
concat it to this url, to get into the FTP of this (meaning the latest) revision
http://commondatastorage.googleapis.com/chromium-browser-continuous/index.html?path=Win/put revision number here/

I’ve made a small VB6 program that uses Win32 API to download the latest revision number and send it to the STDOUT,
and a CMD (batch file) that reads it and use wGet to download the execute.

wget has custom settings like using reffer url, cookie, user-agent, avoiding cache, re-write the mime-type, longer keep-alive, tring few times, downloading backup in case of an error- can re download from the same point,
all like the execute was downloaded from a browser.

::  browse
::  http://commondatastorage.googleapis.com/chromium-browser-continuous/index.html
::  http://commondatastorage.googleapis.com/chromium-browser-continuous/index.html?path=Win/
::  http://commondatastorage.googleapis.com/chromium-browser-continuous/index.html?path=Win/
::  https://commondatastorage.googleapis.com/chromium-browser-continuous/index.html?path=Win/
::  https://commondatastorage.googleapis.com/chromium-browser-continuous/index.html?path=Win/144914/
::  for more information.

@echo off
::static information init.
set sUserAgent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; WOW64; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)"
set sUrl_Protocol=https
set sUrl_Base=commondatastorage.googleapis.com/chromium-browser-continuous/Win
set sUrl_FileName=mini_installer.exe



setlocal enableextensions
    :: sVersionNumber init.
    set sVersionNumber=""
    set sUrl_Version=http://commondatastorage.googleapis.com/chromium-browser-continuous/Win/LAST_CHANGE
    for /f "tokens=*" %%a in ('.\res\getRemoteFileTextContent.exe %sUrl_Version%') do (set sVersionNumber=%%a)
    
    ::dynamic information init.
    set sReferrer="http://commondatastorage.googleapis.com/chromium-browser-continuous/index.html?path=Win/%sVersionNumber%/"
    set sCookie="http://o-o.preferred.fra07t11.v8.cache8.c.bigcache.googleapis.com/chromium-browser-continuous/Win/%sVersionNumber%/mini_installer.exe?ms=tsu&mt=1340990464&cms_redirect=yes&redirect_counter=2"

    ::download execute
    wget "%sUrl_Protocol%://%sUrl_Base%/%sVersionNumber%/%sUrl_FileName%"                                                   ^
                                                                            --no-check-certificate                          ^
                                                                            --wait=2                                        ^
                                                                            --referer=%sReferrer%                           ^
                                                                            --timestamping                                  ^
                                                                            --debug                                         ^
                                                                            --continue                                      ^
                                                                            --no-cache                                      ^
                                                                            --no-cookies                                    ^
                                                                            --no-dns-cache                                  ^
                                                                            --server-response                               ^
                                                                            --auth-no-challenge                             ^
                                                                            --directory-prefix=.                            ^
                                                                            --header="Accept: application/octet-stream"     ^
                                                                            --header="Accept: application/x-msdos-program"  ^
                                                                            --header="Keep-Alive: 300"                      ^

endlocal

pause

to use the script you’ll need the small Execute or any other way of downloading and reading the content of the latest revision number (you can use “curl” compiled for windows, or something…)

and wGet (compiled for win32) placed in the same folder as the script or in the PATH.
download it here:
getRemoteFileTextContent.rar

p.s.

you can have all the new command-line switches for the newest latest version of chromium put in a text file and viewed by notepad++.
use the following CMD (batch) script:

@echo off
rem   set command-line arguments.
set sURL1=http://src.chromium.org/svn/trunk/src/chrome/common/chrome_switches.cc
set sURL2=http://src.chromium.org/svn/trunk/src/base/base_switches.cc
set sUserAgent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTBDFff GTB7.0 (.NET CLR 3.5.30729)"

set sFile=switches.cc

rem   remove old files.
if exist %sFile%   del /f /q %sFile%   >nul

rem   download.
wget --directory-prefix=. --user-agent=%sUserAgent% --output-document=%sFile% %sURL1% %sURL2%
rem ren %sFile% %sFile%_

start "D:\Software\Notepad++\Notepad++.exe" "%CD%\%sFile%"

you will need to modify the full url to Notepad++, or put its path in your PATH variable and just use “Notepad++.exe”, you will also need a wget compiled for win32 platform (or x64) just google it.

____—-____—-
March 2014: here is a working update:
it uses wGet, but you can also throw the link into any parallel download manager to speed things up a little, it uses a session cookie to fool the web-server a little bit..

::  browse
::  http://commondatastorage.googleapis.com/chromium-browser-continuous/index.html
::  http://commondatastorage.googleapis.com/chromium-browser-continuous/index.html?path=Win/
::  http://commondatastorage.googleapis.com/chromium-browser-continuous/index.html?path=Win/
::  https://commondatastorage.googleapis.com/chromium-browser-continuous/index.html?path=Win/
::  https://commondatastorage.googleapis.com/chromium-browser-continuous/index.html?path=Win/144914/
::  for more information.


::static information init.
set sUserAgent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; WOW64; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)"
set sUrl_Protocol=https
set sUrl_Base=commondatastorage.googleapis.com/chromium-browser-continuous/Win
set sUrl_FileName=mini_installer.exe
set sOrbitDownloaderExeFullPath=C:\Program Files (x86)\Orbitdownloader\orbitdm.exe


setlocal enableextensions
    :: sVersionNumber init.
    set sVersionNumber=""
    set sUrl_Version=http://commondatastorage.googleapis.com/chromium-browser-continuous/Win/LAST_CHANGE
    for /f "tokens=*" %%a in ('.\res\getRemoteFileTextContent.exe %sUrl_Version%') do (set sVersionNumber=%%a)
    
    ::dynamic information init.
    set sReferrer="http://commondatastorage.googleapis.com/chromium-browser-continuous/index.html?path=Win/%sVersionNumber%/"
    set sCookie="http://o-o.preferred.fra07t11.v8.cache8.c.bigcache.googleapis.com/chromium-browser-continuous/Win/%sVersionNumber%/mini_installer.exe?ms=tsu&mt=1340990464&cms_redirect=yes&redirect_counter=2"

    set sURL=%sUrl_Protocol%://%sUrl_Base%/%sVersionNumber%/%sUrl_FileName%



    ::option #1.
    ::-------------------------------------------
    wget --no-check-certificate                          ^
         --wait=2                                        ^
         --referer=%sReferrer%                           ^
         --timestamping                                  ^
         --debug                                         ^
         --continue                                      ^
         --no-cache                                      ^
         --no-cookies                                    ^
         --no-dns-cache                                  ^
         --server-response                               ^
         --auth-no-challenge                             ^
         --directory-prefix=.                            ^
         --header="Accept: application/octet-stream"     ^
         --header="Accept: application/x-msdos-program"  ^
         --header="Keep-Alive: 300"                      ^
         "%sURL%"
    
    ::option #2.
    ::-------------------------------------------
    ::call "%sOrbitDownloaderExeFullPath%" "%sURL%"
    
endlocal

Deflate Folder Tree

This is a CMD (BATCH) script to flat a folder tree,
all files will be moved to the root.

for /r %%e in (*.*) do move "%%e" .\

working recursively, a user interaction would be needed when ever two files with the same name exist in the root, also you might wanna use attrib to remove all hidden and system attributes because CMD does not behave well with does on.

proper way to make it work: put the script into a bank cmd (or bat) file,
put it in the root folder and run it, you can modify it to work without user interaction.