<http://www.netikka.net/tsneti/info/tscmd183.php>
Copyright © 2003-2012 by Prof. Timo Salmi  
Last modified Mon 23-Apr-2012 06:08:52
Welcoming the user from 107.22.126.144
On Mon 23-Oct-2017 20:09:08 local time

 
Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index
 

This page is edited from the 1cmdfaq.txt faq-file contained in my tscmd.zip command line interface (CLI) collection. That zipped file has much additional material, including a number of detached .cmd script files. It is recommended that you also get the zipped version as a companion.

Please see "The Description and the Index page" for the conditions of usage and other such information.



183} How do I get the fileurl of a local filename?

  @echo off & setlocal enableextensions
  ::
  :: The local target file

  set filename_=%~1
  ::
  :: Process

  for /f "tokens=*" %%f in ("%filename_%") do (
    set dr_=%%~df
    set ph_=%%~pf
    set nx_=%%~nxf)
  set "fileurl_=file:///%dr_:~0,1%^|%ph_:\=/%%nx_%"
  set "fileur2_=file:///%dr_:~0,1%|%ph_:\=/%%nx_%"
  ::
  :: Display the results

  echo %filename_%
  echo %fileurl_%
  ::
  :: Build a Visual Basic Script for lowercase

  set vbs_=%temp%\tmp$$$.vbs
  set skip=
  findstr "'%skip%VBS" "%~f0" > "%vbs_%"
  ::
  :: Run it with Microsoft Windows Script Host Version 5.6

  cscript //nologo "%vbs_%" "%fileur2_%"
  ::
  :: Clean up

  for %%f in ("%vbs_%") do if exist %%f del %%f
  endlocal & goto :EOF
  '
  'The Visual Basic Script

  WScript.Echo LCase(WScript.Arguments.Unnamed(0)) 'VBS

The output could be e.g.
  C:>C:\_D\TEST\CMDFAQ.CMD C:\_G\WWW\~NETIKKA\FAQ\INFO\TSCMD183.PHP
  C:\_G\WWW\~NETIKKA\FAQ\INFO\TSCMD183.PHP
  file:///C|/_G/WWW/~NETIKKA/FAQ/INFO/TSCMD183.PHP
  file:///c|/_g/www/~netikka/faq/info/tscmd183.php

The other way round would be
  @echo off & setlocal enableextensions
  set fileurl_=%~1
  echo %fileurl_%
  set filename_=%fileurl_:/=\%
  set filename_=%filename_:file:\\\=%
  echo %filename_%
  endlocal & goto :EOF

The output could be e.g.
  C:\_M>C:\_D\BAS\CMDFAQ.CMD "file:///C:/_G/WWW/~NETIKKA/FAQ/INFO/TSCMD183.PHP"
  file:///C:/_G/WWW/~NETIKKA/FAQ/INFO/TSCMD183.PHP
  C:\_G\WWW\~NETIKKA\FAQ\INFO\TSCMD183.PHP