We created the files doing research and have thousands of them with the following name format:
DATA2_<date>_<gridno>_<height>_<delta>
For example:
data2_22-Jun-2011_112_17.8571_22
data2_21-Jun-2011_86_22.9885_22
Basically, a bunch of fields separated by underlines. There are two problems with these names. First, we were - well, he was :) - supposed to use length, not height, and we need all the fields to have the same length (so all the filenames are the same length). In other words, I need this code Bash script, using regexp:
[LIST=1] [*] Get next (or first) file (call it fname) [*] Parse fname by "_" into fields [I]data2[/I], [I]date[/I], [I]grid[/I], [I]height[/I], [I]delta[/I]. [*] Let length=grid*height [*]Left and right pad [I]length[/I] with zeros so all the same length. [*]Left pad [I]grid [/I]with zeros so they're all the same length [*] Let newfilename = concatenate fields [I]data2[/I], [I]date[/I], [I]grid[/I], [I]length[/I], [I]delta[/I], with "_" separator. [*] Rename fname to newfilename [*] Get next file (or end) [/LIST]I don't know how to do any of this in BASH and (frankly), don't have the time to learn a whole new language right now (my thesis is due soon). So...
Can someone get me started programming this? Can someone (could be the same person :) ) point me to a good BASH programming tutorial?
Thanks much!
Jeff


Sign In
Create Account

Back to top









