## Recursively "trim trailing spaces?"

Find, replace, find in files, replace in files, regular expressions

### Recursively "trim trailing spaces?"

Hello All,

Is it possible to trim all trailing spaces from a group of files in a directory recursively?

In other words, I have a directory with several thousand files that have a fixed width of 120 bytes; however, each file is padded with spaces at the end of the line. Does UltraEdit posses a feature that would do this automatically, or is it possible to create a macro to do this? (If a macro is the answer, where would I start?) Or would regular expression be the way to go?

Shawn

shawn149
Newbie

Posts: 2
Joined: Mon Nov 01, 2004 12:00 am

### Re: Recursively "trim trailing spaces?"

I don't have time to play with it, but I'd first try a regular expression replace in files - something like "find all occurrences of the end of a line which are preceded by one or more spaces and replace with nothing"

mrainey56
Master

Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

### Re: Recursively "trim trailing spaces?"

Thanks for the hint mrainey56!

My solution (as you guessed) was as follows:

I used UltraEdit's "Replace in Files" with the following items:

Find: " ++\$" Without the quotes
Replace With: Empty
In Files/Types: *.*
Directory: C:\etc...
Regular Expressions: Checked
Search Subdirectories: Checked

This regular expression removed the trailing spaces from each line in every file in the directory that I specified.

shawn149
Newbie

Posts: 2
Joined: Mon Nov 01, 2004 12:00 am