Program652
asked on
replacing four spaces in a text file
I have a text file (output of the dsquery command of several fields) that has a delimiter of four spaces. I need to change the delimiter to something else (since data in some of the lines contain a single space) so I can import the file into a table. I have a batch file (see code) that is close, but no cigar. I cannot get the delims to see *multiple* spaces as a delimiter. The behavior is to handle *any* number of spaces as one (1).
I have to deal ONLY in BATCH.
No windows scripting,
No third party utilities.
Ideas how to do this?
I have to deal ONLY in BATCH.
No windows scripting,
No third party utilities.
Ideas how to do this?
for /f "skip=2 tokens=1-5 delims= " %%i in (filename.txt) do @echo %%i~%%j~%%k~%%l
ASKER
Find attached below a small sample (I changed names to protect the innocent) of the text file generated by the command:
dsquery * ou=accounts, dc=mydom,dc=net -limit 0 -attr mail cn givenname samaccountname sn showinaddressbook > test.txt
[As you can tell, I am querying for these fields from AD.]
Please note that
1) as far as I can tell, I cannot specify the delimiter of the dsquery command (else I would not have this problem!) and
2) our cn's have a space between the last and first name. (this is also a problem with my original for loop.
test.txt
dsquery * ou=accounts, dc=mydom,dc=net -limit 0 -attr mail cn givenname samaccountname sn showinaddressbook > test.txt
[As you can tell, I am querying for these fields from AD.]
Please note that
1) as far as I can tell, I cannot specify the delimiter of the dsquery command (else I would not have this problem!) and
2) our cn's have a space between the last and first name. (this is also a problem with my original for loop.
test.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nice! Thanks :-)
Open in new window