Simple Cleanup Script

wonder

Expert
Licensed User
Longtime User
If you're using Linux, Git Bash on Windows, or any other viable option that allows you to run bash scripts, you may use this to cleanup your source files:

*** Remember to backup your files first!!! ***
B4X:
#!/bin/bash
#Project Cleanup Script
# - Replaces all tabs with 4 spaces
# - Removes all trailing white space

sed -i 's/\t/    /g' *.b4a
sed -i 's/\s*$//g'   *.b4a
sed -i 's/\t/    /g' *.bas
sed -i 's/\s*$//g'   *.bas
*** Remember to backup your files first!!! ***
 
Last edited:

thedesolatesoul

Expert
Licensed User
Longtime User
Nice.:)
There is also a sed version for windows, so we can do this in .bat, and remove the dependency from bash.
Also, I would prefer to not do inline replacement, as you said, just do the backup in this same script. i.e. sed "regex" infile > outfile && mv infile infile.old && mv outfile infile
...and if you really want to make sure it works, also run a b4a commandline compile, and check it all compiles, and then autocommit!
 
Top