Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.036 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'from:addr:python': 0.09; 'subject:files': 0.09; 'subject:file': 0.13; 'comma': 0.16; 'eg.': 0.16; 'filename,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'reply-to:addr:python-list': 0.16; 'sally': 0.16; 'wrote:': 0.16; 'file,': 0.21; 'header:In-Reply- To:1': 0.22; 'random': 0.28; 'separate': 0.28; 'received:84': 0.28; 'list': 0.32; "isn't": 0.33; 'to:addr:python-list': 0.33; 'named': 0.33; 'header:User-Agent:1': 0.34; 'checking': 0.34; 'directory.': 0.34; 'reply-to:addr:python.org': 0.34; 'subject:text': 0.35; 'file': 0.36; 'pull': 0.37; 'listed': 0.37; 'but': 0.37; 'could': 0.38; 'hello,': 0.38; 'some': 0.38; 'move': 0.38; 'subject:: ': 0.39; 'characters': 0.39; 'persons': 0.39; 'format.': 0.39; 'data': 0.39; 'to:addr:python.org': 0.39; 'more': 0.60; 'john': 0.62; 'business': 0.70; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.71; 'directories,': 0.84; 'stone,': 0.84; 'stone': 0.91 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlgHACgnWU7Unw4S/2dsb2JhbAA4Cph0jxt3gUABAQU4QBELCBAJFg8JAwIBAgENOBMGAgEBh3CtRos5gyiDJASLZEmMAIt3 Date: Sat, 27 Aug 2011 18:22:58 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0) Gecko/20110812 Thunderbird/6.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Arrange files according to a text file References: <6j8i57t6cgqunn3c1ci4p7u9mnpnvsrl8s@4ax.com> In-Reply-To: <6j8i57t6cgqunn3c1ci4p7u9mnpnvsrl8s@4ax.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1314465840 news.xs4all.nl 2550 [2001:888:2000:d::a6]:46991 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12277 On 27/08/2011 18:03, Ric@rdo.python.org wrote: > Hello, > > What would be the best way to accomplish this task? > I have many files in separate directories, each file name > contain a persons name but never in the same spot. > I need to find that name which is listed in a large > text file in the following format. Last name, comma > and First name. The last name could be duplicate. > > Adler, Jack > Smith, John > Smith, Sally > Stone, Mark > etc. > > > The file names don't necessary follow any standard > format. > > Smith, John - 02-15-75 - business files.doc > Random Data - Adler Jack - expenses.xls > More Data Mark Stone files list.doc > etc > > I need some way to pull the name from the file name, find it in the > text list and then create a directory based on the name on the list > "Smith, John" and move all files named with the clients name into that > directory. I would get a name from the text file, eg. "Adler, Jack", and then identify all the files which contain "Adler, Jack" or "Adler Jack" or "Jack Adler" in the filename, also checking the surrounding characters to ensure that I don't split a name, eg. that "John" isn't part of "Johnson".