Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I have something like set value = c:\\some\\path

I want to convert this to c:\some\path.

How do I do this?

share|improve this question

migrated from stackoverflow.com May 29 '13 at 5:30

This question came from our site for professional and enthusiast programmers.

1  
Why the close vote? Shell programming is valid for SO. –  Preet Sangha May 28 '13 at 23:48
    
I agree this seems like an arbitrary move to SuperUser. It fits right in with StackOverflow in my mind. –  dbenham May 29 '13 at 21:00
    
SO is a really funny well "reputated" & sophisticated forum (rofl)! –  Endoro May 31 '13 at 8:10
add comment

1 Answer 1

up vote 3 down vote accepted

From Here you can use string replace.

@echo off
set value=c:\\some\\path
echo %value%
set new_value=%value:\\=\%
echo %new_value%

output

c:\\some\\path
c:\some\path

(yes I just learned this trick too)

That Link also has

Align Right          Align text to the right i.e. to improve readability of number columns.
Left String          Extract characters from the beginning of a string.
Map and Lookup       Use Key-Value pair list to lookup and translate values.
Mid String           Extract a Substring by Position.
Remove               Remove a substring using string substitution.
Remove both Ends     Remove the first and the last character of a string.
Remove Spaces        Remove all spaces in a string via substitution.
Replace              Replace a substring using string substitution.
Right String         Extract characters from the end of a string.
Split String         Split a String, Extract Substrings by Delimiters.
String Concatenation Add one string to another string.
Trim Left            Trim spaces from the beginning of a string via "FOR" command.
Trim Quotes          Remove surrounding quotes via FOR command.
Trim Right           Trim spaces from the end of a string via substitution.
Trim Right           Trim spaces from the end of a string via "FOR" command.
share|improve this answer
    
Cheers thanks. :) –  user1068446 May 28 '13 at 23:52
    
What did you google to find it btw? –  user1068446 May 28 '13 at 23:52
    
I googled: "windows batch strip" it was the the last on the page! –  Preet Sangha May 28 '13 at 23:54
2  
Or type "help set" in cmd.exe :-). –  Werner Henze May 29 '13 at 9:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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