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



Darin Strait <darin_strait@yahoo.com> writes:

> 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.

U N T E S T E D :
-----------------

find olddir -type d | while read d; do mkdir "`echo \"$d\" | sed s,^olddir,newdir,`"; done
find olddir -type f -name \*.mp3 | while read f; do mv "$f" "`echo \"$f\" | sed s,^olddir,newdir,`"; done

This duplicates the directory tree `olddir' to `newdir' and moves files
ending in .mp3 to the new tree. Should work with filenames that contain
spaces, but not with filenames that contain line breaks.

Martin



Reply to: