Creating a directory structure and modifying files automatically in Python
deltaquattro at gmail.com
deltaquattro at gmail.com
Mon Apr 30 11:19:15 EDT 2012
Hi,
I would like to automate the following task under Linux. I need to create a set of directories such as
075
095
100
125
The directory names may be read from a text file foobar, which also contains a number corresponding to each dir, like this:
075 1.818
095 2.181
100 2.579
125 3.019
In each directory I must copy a text file input.in. This file contains two lines which need to be edited:
.
.
.
foo = 1.5 !edit me..
.
.
.
bar = 1.5 !..and me, too
.
.
The number after the "=" must be set to the value given in foobar for the corresponding directory
I thought to write a bash/awk shell script for this. However, if and when the script works, I'll probably start to add more features in order to automate even more tasks. It seems to me that Python or perl would be better suited to write a larger, mantainable script. Unfortunately, I know neither of them. Could you show me how to write the script in Python? Thanks,
Best Regards
Sergio Rossi
More information about the Python-list
mailing list