Recursively "trim trailing spaces?"

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

Recursively "trim trailing spaces?"

Postby shawn149 » Mon Nov 01, 2004 10:38 am

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?

Thanks in advance,

Shawn
User avatar
shawn149
Newbie
 
Posts: 2
Joined: Mon Nov 01, 2004 12:00 am

Re: Recursively "trim trailing spaces?"

Postby mrainey56 » Mon Nov 01, 2004 12:15 pm

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"
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Recursively "trim trailing spaces?"

Postby shawn149 » Tue Nov 02, 2004 11:21 am

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.
User avatar
shawn149
Newbie
 
Posts: 2
Joined: Mon Nov 01, 2004 12:00 am


Return to Find/Replace/Regular Expressions