0

Using a batch script, how do I delete the following pattern from the start of a file?

DN: CN=ACME Test,OU=ACME Test Company,O=ACME Big Org    someObject;binary: 

There is a space character after binary: that needs deleting too.

The file contains:

DN: CN=ACME Test,OU=ACME Test Company,O=ACME Big Org    someObject;binary: MI...

The ... indicates lots more character after the MI

I just need the MI and all the characters the follow it to be in the file after the batch script has run

smithy
  • 417
  • 1
  • 7
  • 14

2 Answers2

1

I think what you are looking for is answered here

Batch script to find and replace a string in text file without creating an extra output file for storing the modified file

but instead of taking in the "replace=%2" as an argument and replacing with that, you can just replace with an empty string (or pass an empty string in as the parameter if it will never change)

Community
  • 1
  • 1
dcod
  • 70
  • 1
  • 9
1

with dcod's link you would have to know the first part of the string to replace it with nothing. His link is nearly fine, but to delete from the start to (including) binary;, instead of

set "line=!line:%search%=%replace%!"

use

set "line=!line:*binary: =!"
Community
  • 1
  • 1
Stephan
  • 53,940
  • 10
  • 58
  • 91