C:\_G\WWW\~ELISANET\INFO\tscmd183.html
<http://www.elisanet.fi/tsalmi/info/tscmd183.html>
Copyright © 2003- by Prof. Timo Salmi  
Last modified Tue 25-Dec-2018 11:56:02

 
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\BAS\CMDFAQ.CMD C:\_G\WWW\~ELISANET\INFO\TSCMD183.HTML
  C:\_G\WWW\~ELISANET\INFO\TSCMD183.HTML
  file:///C:/_G/WWW/~ELISANET/INFO/tscmd183.html
  file:///c:/_g/www/~elisanet/info/tscmd183.html

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/~ELISANET/INFO/tscmd183.html"
  file:///C:/_G/WWW/~ELISANET/INFO/tscmd183.html
  C:\_G\WWW\~ELISANET\INFO\tscmd183.html



[Previous] [Next]

C:\_G\WWW\~ELISANET\INFO\tscmd183.html
C:\_G\WWW\~ELISANET\FTPCMD\TSALMI.CMD /tscmd183
http://www.elisanet.fi/tsalmi/info/tscmd183.html
file:///c:/_g/www/~elisanet/info/tscmd183.html