How to convert from DOS path to file scheme URI in batch file

I am trying to write a batch file for svnsync that needs urls for svn repositories. The rest of the batch file uses% ~ dp0 to get the path to the batch file, but this does not work with svnsync.

What is the best way to convert the path (e.g.% ~ dp0repo, which extends to c: \ backup \ repo) to a uri suitable for svnsync (file: /// c: / backup / repo)?

Ideally, it will be able to handle spaces and whatever is not included in this path, so I would prefer not to use any explicit character substitution to convert from path to URL, but if that's the only way, oh, good.

Thank!

+3
source share
1 answer

, , :

  • \ /
  • Stick file:///

:

set DOSPATH=%~dp0repo
set URI=file:///%DOSPATH:\=/%
+4

Source: https://habr.com/ru/post/1791283/


All Articles