views:

142

answers:

2

Hi there,

I need to write a script that takes the current path (%~dp0), transforms backslashes into forward slashes and passes it further to some command.

Due to the environment I'm working in the only option that I have is windows shell (not Powershell where the issue would not a problem).

Is it even possible to do that?

A: 

Hi, try JScript

Just create test.js file with this content and run it

var WshShell = WScript.CreateObject("WScript.Shell");

var currentDir = WshShell.CurrentDirectory;

WScript.Echo ("Current directory: " + currentDir);

WScript.Echo ("Current directory: " + currentDir.replace("\\", "/"));

WshShell.Run("cmd.exe " + currentDir);
Eugene
It has to be a batch file (so no JS, VB or the like).
Matthias Hryniszak
+1  A: 

The set command has a substitution feature:

set a=C:\test\dir
set a=%a:\=/%
echo %a%

Results in:

C:/test/dir
Dennis Williamson
Sweet! That's exactly what I was looking for! short and sweet and to the point :)
Matthias Hryniszak