Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'modify': 0.07; 'string': 0.09; 'extracted': 0.09; 'filename': 0.09; 'non-text': 0.09; 'similar,': 0.09; 'cc:addr:python-list': 0.11; 'command-line': 0.16; 'files)': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'renaming': 0.16; 'replaced.': 0.16; 'subject:son': 0.16; 'transforming': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'directory.': 0.24; 'replace': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; 'least': 0.26; 'certain': 0.27; 'header:In-Reply- To:1': 0.27; 'idea': 0.28; 'fixed': 0.29; 'chris': 0.29; 'sets': 0.30; 'along': 0.30; 'container': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'file': 0.32; 'another': 0.32; 'text': 0.33; 'fri,': 0.33; 'but': 0.35; 'there': 0.35; '14,': 0.36; 'data,': 0.36; 'done': 0.36; 'charset:us-ascii': 0.36; 'operating': 0.37; 'sometimes': 0.38; 'files': 0.38; 'pm,': 0.38; 'extremely': 0.39; 'moving': 0.39; 'challenge': 0.61; 'information': 0.63; 'name': 0.63; 'to:addr:gmail.com': 0.65; 'media': 0.66; 'containing': 0.69; 'subject:wants': 0.74; 'you:': 0.81; 'birthday': 0.84; 'received:50.22': 0.84; '2013': 0.98 Date: Fri, 14 Jun 2013 05:41:20 -0500 From: Tim Chase To: Chris Angelico Subject: Re: My son wants me to teach him Python In-Reply-To: References: <637daa98-9a0e-46ab-bb9a-f5638b7c0038@googlegroups.com> <51bab49a$0$29997$c3e8da3$5496439d@news.astraweb.com> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371206377 news.xs4all.nl 15986 [2001:888:2000:d::a6]:39979 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48112 On 2013-06-14 17:21, Chris Angelico wrote: > On Fri, Jun 14, 2013 at 4:13 PM, Steven D'Aprano > 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