how can I remove white space in a string and replace it with (;) in batch

user4722671

How can I remove white space from this string or replace space with ; in batch?

ECHO    V00000023903507 92  30573185    E28FC1  2015079 18-04-2015  27-04-2015  >>  %EXT%

I want it to look like this:

ECHO V00000017495345;90;30485020;FD2ECC;2015079;08-04-2015;19-04-2015 >> %EXT%
rojo

You could use delayed expansion and a for loop.

@echo off
setlocal enabledelayedexpansion

set "str=    V00000023903507 92  30573185    E28FC1  2015079 18-04-2015  27-04-2015  "

set "fixed="
for %%I in (%str%) do (
    if not defined fixed (set "fixed=%%I") else set "fixed=!fixed!;%%I"
)

>>outfile.txt echo %fixed%

Or you could use variable substring substitution.

@echo off
setlocal

set "str=    V00000023903507 92  30573185    E28FC1  2015079 18-04-2015  27-04-2015  "

rem // replace tab with space (the blank character after : is a tab)
set "str=%str:  = %"

rem // replace all multiple spaces with single
set "str=%str:  = %"

rem // replace all spaces with ;
set "str=%str: =;%"

rem // remove first and last character
set "str=%str:~1,-1%"

>> outfile echo %str%

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How do I replace a set of single characters and white space with the same characters but no white space

분류에서Dev

How can I remove all white parts from an image in Photoshop?

분류에서Dev

How can I remove space between body and top of page

분류에서Dev

How to remove Page Header White Space in SSRS report

분류에서Dev

how to remove unwanted vertical white space in visual studio 2013

분류에서Dev

How can I extract text before a character or string in a batch file?

분류에서Dev

How to include white space when searching for a string in text file

분류에서Dev

How should i replace double space(continuous space) by double characters?

분류에서Dev

How can I remove something from the middle of a string with regex?

분류에서Dev

How do I remove the first two words in string which aren't separated by a space?

분류에서Dev

How can I remove Ubuntu from my dual-boot and replace it with another distribution?

분류에서Dev

How to replace the first blank space, within a string, with a different character?

분류에서Dev

How can I evenly space icons in the panel?

분류에서Dev

Python string clean up: How can I remove the excess of newlines of a string in python?

분류에서Dev

Python string clean up: How can I remove the excess of newlines of a string in python?

분류에서Dev

How can I use string manipulation to detect and remove two different parts of a string?

분류에서Dev

How can I check in Apex if a batch is scheduled?

분류에서Dev

How can I call a batch file within another batch file?

분류에서Dev

php How can I replace a character in a string (only) when it is in a certain place?

분류에서Dev

how do i remove the space at at the end of the column header?

분류에서Dev

MVC - How to check for white space in a text box

분류에서Dev

Need to remove white space between two tags with Regex

분류에서Dev

While loop through file names and remove white space

분류에서Dev

Remove single white space from end of lines for .TXT file

분류에서Dev

How can i replace particular characters in a file

분류에서Dev

How can I replace bash with Python?

분류에서Dev

I am confuse how to replace string preg replace

분류에서Dev

How can I remove empty array

분류에서Dev

Can I use str_replace twice in one string?

Related 관련 기사

  1. 1

    How do I replace a set of single characters and white space with the same characters but no white space

  2. 2

    How can I remove all white parts from an image in Photoshop?

  3. 3

    How can I remove space between body and top of page

  4. 4

    How to remove Page Header White Space in SSRS report

  5. 5

    how to remove unwanted vertical white space in visual studio 2013

  6. 6

    How can I extract text before a character or string in a batch file?

  7. 7

    How to include white space when searching for a string in text file

  8. 8

    How should i replace double space(continuous space) by double characters?

  9. 9

    How can I remove something from the middle of a string with regex?

  10. 10

    How do I remove the first two words in string which aren't separated by a space?

  11. 11

    How can I remove Ubuntu from my dual-boot and replace it with another distribution?

  12. 12

    How to replace the first blank space, within a string, with a different character?

  13. 13

    How can I evenly space icons in the panel?

  14. 14

    Python string clean up: How can I remove the excess of newlines of a string in python?

  15. 15

    Python string clean up: How can I remove the excess of newlines of a string in python?

  16. 16

    How can I use string manipulation to detect and remove two different parts of a string?

  17. 17

    How can I check in Apex if a batch is scheduled?

  18. 18

    How can I call a batch file within another batch file?

  19. 19

    php How can I replace a character in a string (only) when it is in a certain place?

  20. 20

    how do i remove the space at at the end of the column header?

  21. 21

    MVC - How to check for white space in a text box

  22. 22

    Need to remove white space between two tags with Regex

  23. 23

    While loop through file names and remove white space

  24. 24

    Remove single white space from end of lines for .TXT file

  25. 25

    How can i replace particular characters in a file

  26. 26

    How can I replace bash with Python?

  27. 27

    I am confuse how to replace string preg replace

  28. 28

    How can I remove empty array

  29. 29

    Can I use str_replace twice in one string?

뜨겁다태그

보관