RE: Php/python questions:Recursing directories,renaming files,and updating mysql records

  • From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Thu, 18 Jun 2009 22:07:48 -0400

Nod if you have trouble let me know I have used it a lot but I know your
much better at reading docs than your used to but if you have code written
and its not working as you expect let me know.  Note you can do top down or
bottom up depending on what your doing with walk.  It's a powerful tool and
its pretty fast.

Ken

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Tyler
Littlefield
Sent: Thursday, June 18, 2009 9:59 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: Php/python questions:Recursing directories,renaming files,and
updating mysql records

that's awesome, thanks. wasn't aware there was something like that. :d


Thanks,
Tyler Littlefield
Web: tysdomain.com
email: tyler@xxxxxxxxxxxxx
My programs don't have bugs, they're called randomly added features.

----- Original Message ----- 
From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Thursday, June 18, 2009 7:52 PM
Subject: RE: Php/python questions:Recursing directories,renaming files,and 
updating mysql records


>
> No use walk its in the os module.  It does all the work for you.
>
> Ken
>
> -----Original Message-----
> From: programmingblind-bounce@xxxxxxxxxxxxx
> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Tyler
> Littlefield
> Sent: Thursday, June 18, 2009 9:07 PM
> To: programmingblind@xxxxxxxxxxxxx
> Subject: Php/python questions:Recursing directories,renaming files,and
> updating mysql records
>
> Hello list,
> I've got a quick question.
> I would like to index all of my music in a mysql database, with something
> like python.
> First I'd like to recurse through the directories, rename everything with
> spaces, and cap letters to lowercase and replace space with underline. I
> think I could use a str.replace in python, then tolower, and rename the
> file, but I'm a bit confused with the recursing.
> I'm trying to figure out how I'd recurse through a list of directories, 
> say
> I have top level dirs of animals, food, and automobiles,
> Then under each one wsay for animals I have pet, and wild,
> Then pet would have dog, cat, etc.
> I would start at the top level (/), drop to animals, then see pet and 
> wild,
> drop to wild, then cat as it would be the first alphabetically.
> How would I then go back and go to dog (always remembering that I just did
> cat), and once I was done with everything under the pets directory go back
> to animals and move to the next unused directory?
> Second, I'd like to be able to update the database easily, lets say I add 
> a
> new album or artest, the idea would be to run the script that would check
> the list of everything, then add what wasn't there, or update what 
> changed.
> Could I just delete everything in a table and restart?
> I know about drop table, and I suppose I could just use a drop, then 
> create,
>
> but that seems kind of messy.
> I could also use something like select * from music where artest = 
> 'artest',
>
> size='size', but if I add a larger file, it won't catch that and will just
> end up adding a new record, which means I'm left with multiples of the 
> same
> thing.
> Hopefully the message made some sense, and input would be great, as I'm
> slightly lost with this. :)
>
>
> Thanks,
> Tyler Littlefield
> Web: tysdomain.com
> email: tyler@xxxxxxxxxxxxx
> My programs don't have bugs, they're called randomly added features.
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
> 

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: