How to emulate cp and mv --parent on osx

独自空忆成欢 提交于 2019-12-07 05:24:09

问题


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

I.e. mv x/y/a.txt s/x/y/a.txt when s is empty gives a no directory found error unless one does a mkdir first which is rather cumbersome when trying to do this did thousands of files.


回答1:


The solution (which works on all platforms that has an rsync) is:

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

find *.mp3 > files.txt

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

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

Slower than a native mv/cp but its resumable and rsync got alot more options that can otherwise help too for cleaning up your files.



来源:https://stackoverflow.com/questions/3474329/how-to-emulate-cp-and-mv-parent-on-osx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!