Solved: CMD – Comma And Apostrophe In File Name

working with com.whatsapp_2.17.35' 8-452027_minAPI15(armeabi,armeabi-v7a,mips,x86)(nodpi),
the %1, %~1 tries to parse a list of arguments
and will give you: com.whatsapp_2.17.35' 8-452027_minAPI15(armeabi.

%~s1 will fail too.

A workaround:
gulp the entire thing,
and re-parse content into short-path for easier usage.

@echo off
::                              enable Unicode support for path/file-name.
chcp 65001 2>nul >nul

::                              single arg - workaround weird file-name.
set "ARG=%*"
for /f %%a in ("%ARG%") do ( set 'ARG=%%~fsa' )

pure CMD:
the code above will generate a fully-qualified,
short (8.3-DOS like) path.

if you do need to pass more than one argument,
this is not the solution for you.

– – – – – –

The above code does not always works
since it will turn off any tries to parse single argument from the string,

Passing %* to other programs as an argument will always work,
but built-in handling of file-names, with apostrophes will still fail,
due to “by design” issues in CMD (wrapping phrases uses apostrophes..)

instead, try passing %* to GetShortPathName.exe from,
with the additional processing allowing empty-strings/empty-character (\0) and Windows API.
it will return a short 8.3 version of the path (relative or full),
if you want a fully qualified path try using GetFullPathName.exe from

You can use your choice of implementations, that simple one is written in VB6.

CMD NewLine Character

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

And You’ll get


Aria2C Batch File For Quick Download

Copy to following CMD batch-file content into a new file,
and name it aria2download.cmd.

Place the file in the same folder as your aria2c.exe,
make sure it is your system-PATH,

and you can now enter aria2download "http..your-url..."
for a quick file-download to the current folder you are in.

All the important-switches are already set, such as maximum split value, and maximum connections per-server for ultra-fast download and an extra permissive-SSL to allow you to download from secure-servers without certificate verifying and a browser-like useragent and referrer value to generate a compatible download session with servers that often will block download-managers. You can easily personalise the batch-file to include an additional headers, authentications, etc…

Continue reading

cURL – Latest Chromium Downloader

echo off
::stuff you can modify.
::                          http|https
set PROTOCOL=http
::                          snapshots|continuous
set BRANCH=snapshots
::                          Android|Arm|Linux|LinuxGit|LinuxGit_x64|Linux_ARM_Cross-Compile|Linux_ChromiumOS|Linux_ChromiumOS_Full|Linux_x64|Mac|MacGit|Win|WinGit|Win_x64|chromium-full-linux-chromeos
set OS=Win_x64
::                          mini_installer.exe|REVISIONS|||||||remoting-host.msi||||changelog.xml|
set FILE=mini_installer.exe

::stuff you should keep as is.

set COMMAND_CURL_FORVERSION=curl.exe --silent --http2 --ipv4 --anyauth --insecure --location-trusted --ssl-allow-beast --ssl-no-revoke --url "%URL_LASTCHANGE%"

for /f "tokens=*" %%a in ('call %COMMAND_CURL_FORVERSION% 2^>^&1') do (set VERSION=%%a)
::error handling
if ["%VERSION%"] == [""] ( goto NOVERSION )

echo Got Latest-Version: ^>%VERSION%^< ^[Branch:%BRANCH%/OS:%OS%^]

::you should enable one-of-your-prefered downloaders.

::you should not reach here, unless
::you've forgot to enable one of the "downloader lines" (above)...

  echo ERROR: could not get the latest version...
  goto EXIT

  echo ERROR: please enable one of the downloader lines..
  goto EXIT

  echo Start Download using cURL...
  call curl.exe --verbose --http2 --ipv4 --ignore-content-length ^
                --anyauth --insecure --location-trusted          ^
                --ssl-allow-beast --ssl-no-revoke --tcp-fastopen ^
                --tcp-nodelay --use-ascii --url "%URL_DOWNLOAD%"
  goto EXIT

  echo Start Download using wGET...
  call wget.exe --directory-prefix="." --debug --user-agent="Mozilla/5.0 Chrome" --continue ^
                --server-response --no-check-certificate --secure-protocol=auto  "%URL_DOWNLOAD%"
  goto EXIT

  echo Start Download using Aria2C...
  call aria2c.exe --allow-overwrite=true         --auto-file-renaming=false         --check-certificate=false        ^
                  --check-integrity=false        --connect-timeout=120              --console-log-level=notice       ^
                  --continue=true                --dir="."                          --disable-ipv6=true              ^
                  --enable-http-keep-alive=true  --enable-http-pipelining=true      --file-allocation=prealloc       ^
                  --http-auth-challenge=false    --human-readable=true              --max-concurrent-downloads=16    ^
                  --max-connection-per-server=16 --max-tries=3                      --min-split-size=1M              ^
                  --retry-wait=1                 --rpc-secure=false                 --split=8                        ^
                  --timeout=120                  --user-agent="Mozilla/5.0 Chrome"  "%URL_DOWNLOAD%"
  goto EXIT

  echo Start Download using OrbitDownloader...
  call "C:\Program Files (x86)\Orbitdownloader\orbitdm.exe" "%URL_DOWNLOAD%"
  goto EXIT

  echo Done.

::   - "http"           - http protocol is faster to connect and download with OrbitDownloader and wGet, it also means your PC won't preform certificate exchange with the remote machine.
::   - "snapshots"      - snapshots is newer, "continuous" is more stable (but might be very old).
::   - "OS" and "FILE"  - are what you want to download
:: snapshots    - newest (unstable) newest code-changes - passed unit-tests + compilation.
:: continuous   - old    (stable)                       - passed unit-tests + compilation + test-suits.
:: ------------------------------------------------------------------------------------------------------
::   branch   |  branch description           |  version-based build
:: ___________|_______________________________|_____________________________________________________________________________________________
::   Win_x64  |  Chromium Installer (64-bit)  |{version}/mini_installer.exe  
::   Win_x64  |  Chromium Package (64-bit)    |{version}/    
::   Win      |  Chromium Installer (32-bit)  |{version}/mini_installer.exe
::   Win      |  Chromium Package (64-bit)    |{version}/    

Download tools..

FFMPEG Use In Product Review For Time-Lapse

I’ve bought 3 clocks from eBay seller (good4deal999) that offered a “Travel Quartz” quality clocks,

When two of the 3 started showing wrong hour I’ve decided to record them all together for as long as my phone’s camera will allow (two hours with the lowest pixel settings)

They are all the SAME initial state (the one on the left is just at an angle to the camera)

In-fact the one on the right even got the first battery, so it should, be ahead in few seconds but it is delayed for -5 minutes every ~hour.
The one in the middle is just F*CKED up entirely. the one on the left, as the ONLY one actually working :..(

– – – – – –
Took it with my Samsung phone on tripod.
Original file: 20160912_003810.mp4
Recorded video was two hours and 18 minutes (2:18:23) and about 3 Gigabytes (3.22GB)
Resolution is VGA 640x480, which is quite low but in close-up.
In order to rotate it (filmed on the side), fix it (double frames due to Samsung’s camera bug), remove background sound of me (kind’a) snoring (it was just before bed), make it ready for web-streaming better and speed it up x5 times more fast (which saves me uploading 3Giga, plus it helps identify the problem better
I’ve used the following FFMPEG command line:

ffmpeg -y -hide_banner -i 20160912_003810.mp4 -an -vf "transpose=2,mpdecimate,setpts=N/FRAME_
RATE/TB,setpts=0.2*PTS" -preset veryslow -tune zerolatency -pix_fmt yuv420p -movflags "+faststart" -crf 23 "output.mp4"

Full FFMPEG Output:
Continue reading

Synapse Knox Missed Packages


Enterprise / Knox / Folder Isolation Related-Packages
That You Should Disable After Choosing “Disable Knox” From Synapse’s Security-Menu.

successfully disabled by Synapse (

need to do it manually

– activate USB debugging.
– connect your phone using USB (or network..) run adb devices
– run adb shell
– – run su [ENTER]
– – run pm disable ___package name____
(replace “___package name____” with the package-names above)
– – run exit and again exit until you’ll be back to your Windows’s CMD (or if you’re using *nix — the terminal..).
– – – if you are using TWRP you can use its terminal for an extra clean results (before first-boot!)

– reboot your device.

.htaccess Trick To Proper Download Binary-Files

Add this to the .htaccess at your website’s root.
It will make sure binary files are
– fully supported on parallel and multi-download managers.
– explicit download-supported on older browsers.
– not sniffed for type (first few bytes).
– have proper name addition to Content-Disposition, even long names are supported.

the rule below includes a lot of extension
mostly I’ve extracted from 7Zip, WinRAR, WinZip, Adobe Audition and UltraISO.

it also prevents files from being executed from your website,
on client’s desktop or mobile phone, especially XPI (Firefox extension) and CRX (Chrome extension)
which won’t be jumping warnings from the browser (so you can finally host them safely).

naturally don’t expand the rule below to web-extensions such as PHP, HTM, HTML, swf or JS otherwise your website file will suddenly be downloaded instead of being parsed..

old file-extensions such as vbs are recommended to being added, again this adds security measure, to prevent script execution (mostly from Internet-Explorer users) on their desktops.

<FilesMatch "\.(?i:000|001|002|7z|7zip|ace|aif|ape|arj|ashdisc|au|avi|b5i|b5t|b64|b6i|b6t|bat|bhx|bif|bin|bwi|bwt|bz2|bzip|bzip2|c2d|cab|ccd|cda|cdi|cel|cif|cmd|command|cpio|cpx|cue|daa|dao|db|dbl|deb|dmg|dvd|dwd|fat|fcd|fla|flac|flp|gi|gz|gzip|hfs|hqx|iff|ima|img|iso|isz|jar|lcs|lha|lzh|lzma|m4a|mac|mdf|mds|mim|mp\+|mp\+\+|mp1|mp2|mp3|mp4|mpc|mpg|mpp|ncd|nrg|ntfs|off|p2i|pcm|pdi|pxi|rar|raw|reg|rif|rpm|sam|smp|snd|sql|sql3|sqlite|squashfs|svx|swm|tao|tar|tar\.md5|taz|tbz|tbz2|tgz|timg|tpz|txz|tz|uif|uue|vbs|vc4|vhd|voc|vox|wav|wim|wma|xar|xmd|xmf|xpi|xz|z|zip|zipx)$">

##optional - will force download, but will also make HTML5 resources for audio/video not-work no older browsers.
#  <IfModule mod_mime.c> 
#    ForceType application/octet-stream
#  </IfModule>

  <IfModule mod_headers.c> 
    ##fix a bug in old GoDaddy servers.
    Header unset X-Content-Type-Options
    Header unset Content-Disposition

    ##prevent mimetype sniffing (first few bytes can determine that a file should be opened in browser).
    Header set X-Content-Type-Options "nosniff"

    ##extract filename, apply to proper (for example) Content-Disposition: attachment; file="my music.mp3"
    SetEnvIf Request_URI "^.*/([^/]*)$" FILENAME=$1
    Header set "Content-Disposition" "attachment;filename=\"%{FILENAME}e\""
    UnsetEnv FILENAME


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

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

      ::-------------------------- 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
      goto loop


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

is a directory

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

is a file

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

is a directory
is a file
is a file
not exist

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

also posted at StackOverflow:

Explorer To Cygwin – Open In Folder

replace the Cygwin.bay under c:\cygwin\ with this content,

@echo off
::force UTF-8 support
chcp 65001

if "%1"=="" (
) else (

  call C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -
  goto EXIT

  rem  remove [\'\"] from first arg
  set CURRENT=%~1
  rem  backward2forward slash
  rem  remove ":" after the drive letter
  set CURRENT=%CURRENT::/=/%
  rem  adds prefix (used in cygwin as dummy drive-mounts)
  set CURRENT=/cygdrive/%CURRENT%
  rem  ------------------------------------------------------------
  call C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico c:\cygwin\bin\bash.exe -l -c "cd \"%CURRENT%\" ; exec bash" -
  goto EXIT


or download the following file instead: Cygwin.bat (here is the original file: Cygwin.bat.bak)

if you’ll pass a folder path as argument to the batch (no checks.. q&d..) it will open cygwin in this path, in any other case, just open cygwin in home-directory (standard run..)


place a shortcut in your SENDTO folder,
and then right-click a folder and select the shortcut from the sendto-menu

or better yet, download the following reg file: open_in_cygwin.reg and double click it,

Windows Registry Editor Version 5.00

@="Open In Cy&gwin"

@="\"C:\\cygwin\\Cygwin.bat\" \"%1\""

it will add a new context-menu item for each folder:

download and run the following file to uninstall the context-menu item: open_in_cygwin_uninstall.reg

Windows Registry Editor Version 5.00


July 29th, 2017 – Update.

Here is a slightly modified version of the “start cygwin from a folder”, that runs few checks before the actual execute stage, it wraps things with ", and very carefully handles long and short paths, passing paths correctly to cygwin terminal application, also, it does not uses hard-coded paths, so if your cygwin folder placed somewhere else it will work just fine for you :]

@echo off
::              set code-page for UTF-8 charset.
chcp 65001

::              normalise to fully qualified path. short path (8.3) is used for testing the path.
set FOLDER=%~s1
for /f %%a in ("%FOLDER%") do ( set "FOLDER=%%~fsa" )

::              verify existing folder.
if ["%FOLDER%"]==[""]         ( goto RUN_STANDARD   )
if not exist %FOLDER%         ( goto RUN_STANDARD   )
if not exist %FOLDER%\NUL     ( goto RUN_STANDARD   )



::             prefer long-path.
  set FOLDER=%~1
  echo Starting Cygwin From ^[%FOLDER%^] ...
::             convert to cygwin-compatible path (forward-slash, removing drive's ":" and /cygdrive/ as root)
  set FOLDER=%FOLDER:\=/%
  set FOLDER=%FOLDER::/=/%
  set FOLDER=/cygdrive/%FOLDER%
  call "%~dp0bin\mintty.exe" "-i" "/Cygwin-Terminal.ico" %~dp0bin\bash.exe -l -c "cd \"%FOLDER%\"; exec bash" - 2>nul >nul
  goto EXIT

  echo Starting Cygwin From Home...
  call "%~dp0bin\mintty.exe" "-i" "/Cygwin-Terminal.ico" "-"   2>nul >nul
  goto EXIT


CMD/Bash Script Ninja – cURL Response Header Number Manipulation

Use cURL response headers using either --head or --include (to include the headers with the response-body),

For the following example we will use GREP, SED (gnu can be compiled either Win32 or Linux, heck! even use cygwin in Windows [as long you put the c:\cygwin\bin\ in PATH, it is super easy])
and Content-Length response-header,

– no “on screen” output (perfect for in-scripts)
– no temporary-file saving (R/O I/O are considered bad practice.. and slow..)
– working out PIPE action (suitable for both Windows and Linux)
– processing and simple arithmetics on value (no just a “stupid” string..)

@echo off

setlocal enableextensions
  for /f "tokens=*" %%a in ('curl --head --ipv4 --sslv3 --silent --location-trusted --url "" 2^>^&1 ^| grep "Content-Length" 2^>^&1 ^| sed "s/\r\n$//g" 2^>^&1 ^| sed "s/content-length\:\ //gi" 2^>^&1') do ( set /a num=%%a )
  set /a num=%num% / 1024 / 1024
  echo it is %num%MB

will output

it is 41MB

(original header was Content-Length: 43597312)

(naturally a pure bash variable output is simpler.. but interior of pipe processing is still -kind’a- similar, and thus- useful or at least quite interesting..)

Hope it will be useful I’ve saw no StackOverflow nor any Google-related resources providing anything similar to that..

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.