NEWbie asks "is Python a good tool for automated file/folder generation?"

Unconditional Grace UG at LY
Fri Jun 14 12:35:01 EDT 2002


Hi all,

I'm so new that "newbie" doesn't even do me justice, and I'm writing
humbly for advice.

I have a series of scientific image files numbering, say, 1000, which
are really 100 groups, each group with its own identical string, but
appended with a different number from _01 to _10, or possibly some
other string.  The end enumeration is ALWAYS differentiated from the
constant string by a final underscore, but the strongs themselves
contain underscores too.

i.e.,
stringa_01.jpg
...
stringa_10.jpg
stringb_01.jpg
...
stringb_10.jpg
...


What I would like to do is largely string-based file and folder
manipulation:

1.  Create a folder for each group of 10, where the folder name is the
shared string for that group (no numbers).  This list of string names
could come directly from the directory, or I could perhaps port the
directory listing to a text file and parse that.

2.  Move each image into its appropriate folder.

3.  Within each folder, create one HTML page consisting of a table
with a link to each image, preferably with a thumbnail (can be
original image resized by HTML since this is all local = no bandwidth
issues).

4.  Create a top level HTML page that links to all 100 image HTML
pages created in step 3.  Can be text only.

5.  Optional:  in step 3, make each image part of an HTML page with
"previous image" and "next image" links, rather than just being called
by the browser as a jpg image.

---

I've never used Python, and I'm wondering if you, collectively, think
that Python is a good language to do this.  While it seems like Python
is an incredibly useful tool, I'm not sure I have time right now to
invest in learning it if it can't do this.  It seems I frequently want
to do repetitive Windows file/folder chores like this, so I want to
get smart-like.

If so, could someone please give me some pointers?  If not, other tool
recommendations?  PHP?

I'm not asking anyone to write such code for me, heh heh, but I'd love
it if someone could give me some advice (here or URLs) on folder and
file name operators, "for every item in list" type syntax, and/or
general string operators  (to truncate the numbers from the file
names, e.g.).

Anyhoo, in addition to any news group response, please cc: me on email
(H_J_Fong at hotmail.com) since my server is spotty and I'd hate to miss
your response(s).

Thanks for reading this far, it is a lot to ask, 
Homer



More information about the Python-list mailing list