# Batch File to Remove Blank Space in Text Files



## eipedro (Feb 20, 2011)

Hi my friend,
Everyday a lot of new text files are created in a specific directory by an electronic invoice software. Nobody know why but in the end of the file there are a lot of blank spaces and it is causing a lot of problems when we're going to process all of them.
I removed these blank spaces from the end of the files manually and all files were processed well.
So I'd like to ask if somebody could help me to create a batch to remove double (or more) blank spaces from the files.
Thanks so much


----------



## JMPC (Jan 15, 2011)

This worked for me under XP, I found it on another site. On the command line use the original file name and a new name to represent %1 and %2.

For example: CleanFile.bat OriginalText.txt NewFile.txt


```
@Echo Off
For /F "tokens=* delims=" %%A in (%1) Do Echo %%A >> %2
```


----------

