Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Batchfile: Removing spaces from txt
Name: blink Date: March 22, 2006 at 05:23:10 Pacific OS: XP CPU/Ram: P4 1GB Product: HP
Comment:
I've made a batch file that lists the users in a security group.
It has three options to list the users, samid, samid and description or just the description.
It exports a list like the following:
Account01 Smith, Bob Account02 Rob Johnson
I want to run a command that removes the spaces before the samid and after the displayname. I want the spaces in between the samid and displayname to be reduced to just one space. So the above turns into.
Name: IVO Date: March 22, 2006 at 06:22:02 Pacific
Reply:
Just save the following line as a batch
@For /F "tokens=1-5" %%A in (%1) Do ( Echo %%A %%B %%C %%D %%E >> %2)
Where each variable (%%A, %%B and so on) is separated by a blank. Then type BatchName FileIn FileOut and you are done.
I assume there are max 5 items per line.
0
Response Number 3
Name: IVO Date: March 22, 2006 at 06:25:08 Pacific
Reply:
Sorry, better instead of Echo code @Echo.
0
Response Number 4
Name: blink Date: March 22, 2006 at 06:50:46 Pacific
Reply:
Works wonderful man, thanks!
Is it possible to add a character to the end of each line? Like a ;?
0
Response Number 5
Name: IVO Date: March 22, 2006 at 06:58:42 Pacific
Reply:
Just add what you want after the last variable or between them, e.g.
Echo %%A %%B %%C %%D %%E;
adds ; at the end of the line, while
Echo [%%A] [%%B] [%%C] [%%D] [%%E]
puts brackets around items; in this case you have to adjust the numbers of items per line, e.g. replacing 1-5 with 1-3 and scaling the variables to %%A %%B %%C.
0
Response Number 6
Name: blink Date: March 22, 2006 at 07:42:16 Pacific
Summary: I would like to know how I can remove items from my right-click menu. (when I right click and go to new the items under that menu) Thanks in advance ...
Summary: I have read and re-read all the posts from this forum about removing Me from a dual boot with XP and I still don't know what to do. I have Me on C:\ (first partition)and XP on D:\ (second partition). ...
Summary: How can i remove programms from Autostart? Like the messanger starts every time my pc goes up! How can i remove programms so that they don`t start anymore when the pc goes up? ...