rem removes all trailing spaces from each file iterated, rem and saves them into subfolder "trimmed". rem rem here all files in the current directory, with rem extension "properties" and trailing spaces inside, get rem matched for the loop rem rem NOTE: requires grep and sed on the PATH, use rem http://unxutils.sourceforge.net/ for example mkdir trimmed for /F "usebackq" %%f in (`grep -l -e " $" *.properties`) do sed -e "s/ *$//" %%f > trimmed\%%f