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.095 X-Spam-Evidence: '*H*': 0.81; '*S*': 0.00; 'way:': 0.05; 'subject:files': 0.09; 'wrote:': 0.15; '11:32,': 0.16; 'mkdir': 0.16; 'received:192.168.1.40': 0.16; 'symbolic': 0.16; '(which': 0.20; 'header:In-Reply-To:1': 0.22; 'trying': 0.23; 'structure': 0.23; 'fine': 0.26; 'to:addr:python-list': 0.34; 'header:User- Agent:1': 0.34; 'there': 0.34; 'however,': 0.34; 'quite': 0.34; 'assuming': 0.37; 'but': 0.37; 'using': 0.37; 'received:192': 0.38; 'subject:: ': 0.38; 'think': 0.38; 'easier': 0.39; 'program,': 0.39; 'received:192.168.1': 0.39; 'should': 0.39; 'files,': 0.39; 'to:addr:python.org': 0.39; 'link': 0.63; 'links,': 0.64; 'received:62': 0.67; 'safe': 0.69; 'everything.': 0.84; 'from:addr:t': 0.84; 'presumably': 0.93 Date: Tue, 02 Aug 2011 12:13:35 +0200 From: Thomas Jollans User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110628 Thunderbird/5.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Hardlink sub-directories and files References: <3d2c3d3b-085e-4f3b-903d-726a31e607f4@b34g2000yqi.googlegroups.com> In-Reply-To: <3d2c3d3b-085e-4f3b-903d-726a31e607f4@b34g2000yqi.googlegroups.com> X-Enigmail-Version: 1.2 OpenPGP: id=5C8691ED Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1312280004 news.xs4all.nl 23982 [2001:888:2000:d::a6]:55153 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10709 On 02/08/11 11:32, loial wrote: > I am trying to hardlink all files in a directory structure using > os.link. > > This works fine for files, but the directory also contains sub- > directories (which themselves contain files and sub-directories). > However I do not think it is possible to hard link directories ? > > So presumably I would need to do a mkdir for each sub-directory > encountered? > Or is there an easier way to hardlink everything in a directory > structure?. > > The requirement is for hard links, not symbolic links > Yes, you have to mkdir everything. However, there is an easier way: subprocess.Popen(['cp','-Rl','target','link']) This is assuming that you're only supporting Unices with a working cp program, but as you're using hard links, that's quite a safe bet, I should think. - Thomas