Could anyone tell me how I can print the current working directory with forward slashes, not backslashes, from the Windows command line?

Thanks!

UPDATE: preferably I would like to do this without downloading any special utilities, but that may not be possible.

link|improve this question
feedback

2 Answers

You can do substitutions like this:

C:\WINDOWS\System32>echo %CD:\=/%
C:/WINDOWS/System32
link|improve this answer
+1 Nice, I didn't know you could do this. – Bryan Mar 2 '11 at 23:56
I recommend typing CMD /? to a command prompt and reading the result. Do the same thing with other commands that get special mentions, but IF, SET, and FOR all have little gems hidden in their options. – RBerteig Mar 3 '11 at 6:36
feedback

You could download GNU utilities for Win32 and use sed.

pwd | sed -e 's!\\!/!g'

c:/Windows

Disclaimer, I don't have a windows PC in front of me to test this, but I have used sed on windows to solve similar problems.

link|improve this answer
thank you! ideally i'd like to do this without downloading anything - i'll hang on and see if anyone else suggests anything, otherwise will accept this. – Steve333 Mar 2 '11 at 22:40
1  
The GNUWin32 utilities are pleasant to have around because they can reduce friction just enough for small things like this. They are light weight too, its not a huge commitment like an installation of Cygwin would be. – RBerteig Mar 3 '11 at 6:37
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.