[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: What's the easiest way to move some files in a directory tree?



On Fri, Feb 13, 2004 at 01:15:37PM -0500, Darin Strait wrote:

> I have a large directory tree, with scores of end nodes. Each end node in the 
> tree has a number of files whose names end either in .mp3 or in .flac. 
> 
> I would like to copy the directory structure of the tree, but I want to move 
> files that end in .mp3 to the new tree and leave the .flac files behind.
> 
> What is the easiest way to do that? I was looking at unision, but unison seems 
> to be copy-only; there doesn't seem to be move the flac files.

mkdir /top/of/mp3/dir
cd /top/of/flac/dir
find . -name '*.mp3' -print0 | cpio -0 -pdm /top/of/mp3/dir
# *** DOUBLE CHECK THAT THE FILES GOT COPIED RIGHT BEFORE STEP 2 ***
find . -name '*.mp3' -print0 | xargs -0 rm

If your mp3 dir and your flac dir are on the same filesystem, you'll speed
this up *immensely* if you do -pdml instead of -pdm, because it'll
just create hard links instead of copying the file contents, and it
won't use any significant extra space between step 1 and 2.

-- 
Dave Carrigan
Seattle, WA, USA
dave@rudedog.org | http://www.rudedog.org/ | ICQ:161669680
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL

Dave is currently listening to Diana Krall - I've Got You Under My Skin (When I look In Your Eyes)

Attachment: signature.asc
Description: Digital signature


Reply to: