[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?



>From Darin Strait on Friday, 2004-02-13 at 13:15:37 -0500:
> Hello.
> 
> 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.

If the main point is to leave behind the .flac files, you can try 

rsync -azv --exclude '*.flac' old-directory new-directory

I did a small test, and if you have a directory that initially
looks like this:

old-directory
old-directory/old2
old-directory/old2/aaa
old-directory/old2/bbb
old-directory/old2/aaa.mp3
old-directory/old2/bbb.flac

Then new-directory looks like this:

new-directory/
new-directory/old-directory
new-directory/old-directory/old2
new-directory/old-directory/old2/aaa
new-directory/old-directory/old2/bbb
new-directory/old-directory/old2/aaa.mp3

If you use a slightly different version (note the trailing /)

rsync -azv --exclude '*.flac' old-directory/ new-directory

you get this:

new-directory/
new-directory/old2
new-directory/old2/aaa
new-directory/old2/bbb
new-directory/old2/aaa.mp3

If you play around with rsync you will find other possibilities.
The nice thing about rsync is it allows you to make these kinds
of changes also across the network.  gentoo and debian both use
rsync to keep their mirrors up-to-date.

Conrad



Reply to: