Like I said before, it would be much cleaner if you used plainly a "ls -1" instead of this big python script. Shell is our friend. :-)