Board logo

标题: xcopy文件时如果目标文件夹有该名称则不替换? [打印本页]

作者: linjuming     时间: 2009-10-19 12:14    标题: xcopy文件时如果目标文件夹有该名称则不替换?

我要批量复制 d:\test\ 中的*.css文件到 d:\target\ 文件夹下,如果 d:\target\ 下本身存在有同名文件的就不覆盖(不要提示y/n)。应该怎么写?
作者: newxso     时间: 2009-10-19 15:43

@echo off
set path1=d:\test
set path2=d:\target
for /f "delims=" %%a in ('dir /b "%path1%\*.css"') do (
  if not exist "%path2%\%%a" (
     xcopy "%path1%\%%a" "%path2%\"
  )
)
[ Last edited by newxso on 2009-10-20 at 13:34 ]
作者: balinger     时间: 2009-10-19 19:25
echo n|copy d:\test\*.css d:\target\ /-y