首页 > 解决方案 > OSX 上的 XCOPY 命令

问题描述

我继承了一个在 Windows 机器上构建的遗留项目。我在 OSX 中工作,构建命令之一是:

xcopy /y /r /i /d $(TargetDir)*.* $(TargetDir)$(ConfigurationName)

我几乎没有在 Windows 中工作的经验;但需要替换它才能使构建顺利运行。

如何在 OSX 上运行它?

标签: windowsbashmacosxcopy

解决方案


Xcopy is a DOS / Windows command. To my knowledge there is no way to runs this directly on Mac.

xcopy basically just copy files from one directory to another. Your command runs with these switches:

/y Suppresses prompting to confirm that you want to overwrite an existing destination file.

/r Copies read-only files.

/i If Source is a directory or contains wildcards and Destination does not exist, xcopy assumes Destination specifies a directory name and creates a new directory. Then, xcopy copies all specified files into the new directory. By default, xcopy prompts you to specify whether Destination is a file or a directory.

/d Copies source files changed on or after the specified date only. If you do not include a MM-DD-YYYY value, xcopy copies all Source files that are newer than existing Destination files. This command-line option allows you to update files that have changed.

You could use a tool available on Mac that does something similar instead, such as rsync.
So basically to do the same, you just need to copy things from one folder to another and keep in mind the different switches to take into account how it chooses what to copy.


推荐阅读