How to emulate cp and mv -parent on osx

Osx mv and cp do not have the -parents option, so how do you emulate it?

those. mv x / y / a.txt s / x / y / a.txt, when s is empty, does not give an error found in the directory, unless mkdir is executed first, which is rather cumbersome when they tried to do this, thousands of files were created.

+5
source share
1 answer

Solution (which works on all platforms with rsync):

Use find or some other tool to create a file with the files you want to move / copy, i.e.

find *.mp3 > files.txt

Then use rsync-from files to specify it, and with --remove-source files it behaves like mv -p and works like cp -p without it:

rsync --files-from=files.txt --remove-source-files src dest 

, mv/cp, rsync , .

+4

All Articles