Chris
Chris

Reputation: 337

String manipulation in Batch Files

I have a batch file question

Set "filename=C:\Documents\Example.doc"

I have a string %FILENAME% and I want to replace the C:\ with C::\, without just redefining it, can anyone help?

Upvotes: 0

Views: 3039

Answers (1)

Christian.K
Christian.K

Reputation: 49300

I'm not sure what you want to achieve here, and your variant of putting all of the set command in quotes is awkward, albeit valid, but anyway:

SET filename=%filename:C:\=C::\%

Or you just use the %filename:C:\=C::\% expression in places where you want the other value, without actually changing the content of the Filename variable.

For more details see (the output of) SET /?.

Upvotes: 1

Related Questions