Pattern Matching Given # of Characters and no String Input; use RegularExpressions?

Synonymous sm.synonymous at gmail.com
Sun Apr 17 05:34:42 EDT 2005


Hello,

Can regular expressions compare file names to one another. It seems RE
can only compare with input i give it, while I want it to compare
amongst itself and give me matches if the first x characters are
similiar.

For example:

cccat
cccap
cccan
dddfa
dddfg
dddfz

Would result in the 'ddd' and the 'ccc' being grouped together if I
specified it to look for a match of the first 3 characters.

What I am trying to do is build a script that will automatically
create directories based on duplicates like this starting with say 10
characters, and going down to 1.  This way "Vacation1.jpg,
Vacation2.jpg" would be sent to its own directory (if i specifiy the
first 8 characters being similiar) and "Cat1.jpg, Cat2.jpg" would
(with 3) as well.

Thanks for your help and interest!

S M



More information about the Python-list mailing list