On 2013-06-14 17:21, Chris Angelico wrote: > On Fri, Jun 14, 2013 at 4:13 PM, Steven D'Aprano > <steve+comp.lang.pyt...@pearwood.info> wrote: > > Here's another Pepsi Challenge for you: > > > > There is a certain directory on your system containing 50 text > > files, and 50 non-text files. You know the location of the > > directory. You want to locate all the text files in this > > directory containing the word "halibut", then replace the word > > "halibut" with "trout", but only if the file name begins with a > > vowel. > > That sounds extremely contrived, to be honest.
I've actually done similar, moving sets of media files while renaming & transforming them (id3v2 to set mp3 tags or modify filenames/target-directories; exif/convert for .jpg files) along the way and selecting them, along with container files (select playlists for MP3s). Sometimes the media files are named poorly, but better filename information can be extracted from internal metadata, or can be combined into things like photo-sets (rather than "DSC314159.JPG", I can at least have "2013-04-01 Mom's birthday party 314159.jpg" where the date comes from EXIF data, and a fixed string is replaced. The idea of operating in batch on any data is pretty much always a command-line win. -tim -- http://mail.python.org/mailman/listinfo/python-list