So, I have a bunch of ogg files that I moved to mp3 (I don’t want to start a format/encoder war, I just did it), I wanted to move the old ogg files, I didn’t delete them because probably I need them in the future. To move the files apart the easiest way could be using find and xargs:


find . -iname "*ogg" -print0 |xargs -0 -I {} mv {} /dest/folder/

The problem with this is that all those ogg files would be in /dest/folder/ all together, and I want to have them each in the corresponding subfolder, I was looking and found that some uses “cp –parents” unfortunately it seems that the cp in OS X does not include that.

What I ended up doing.

If you create a package file (.tar for example), the directories are preserved, so, for me the trick was using tar for that purpose.


find . -name "*ogg" -print0 | xargs -0 tar cvf - |(cd /dest/folder/ ; tar xfp -)

You’ll see all those ogg files in the screen as they are “copied” to the destination folder. later you can remove the files with find again.


find . -iname "*ogg" -delete

 

I assume there is a way to remove the files as soon as they have been added to the tar file.

Loading