批处理文件比较两个文件夹退回没有一个文件夹中的文件 [英] Batch file compare two folders return files that aren't in one folder

查看:104
本文介绍了批处理文件比较两个文件夹退回没有一个文件夹中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个批处理文件,将比较两个文件夹的核心和自定义,退回没有自定义的文件的名称。

到目前为止,我有这个code,其中大部分是采取形式堆栈溢出另一个问题。它创建的每个文件夹中的文件阵列。我如何比较呢?

 关闭@echo
SETLOCAL enableDelayedExpansion文件夹::打造阵
设置fold​​erCnt = 0
FOR / FEOL =:delims =%% f由于('DIR / B核)做(
  集/ A folderCnt + = 1
  设置文件夹!folderCnt!= %% F
)::打印菜单
在/ L %% M(11%folderCnt%)做回声%%米 - !文件夹%%中号!
回声(文件夹::打造阵
设置fold​​erCnt = 0
FOR / FEOL =:delims =%% f由于('DIR / B定制​​')做(
  集/ A folderCnt + = 1
  设置文件夹!folderCnt!= %% F
)::打印菜单
对/ L %% N的(11%folderCnt%)做回声%% N - !文件夹%% N!
回声(暂停test.bat的


解决方案

如何

 回声Y | XCOPY / L / D核心\\ *定制\\

这应该列出所有的核心不在定制或不同版本的核心?文件

I'm trying to make a batch file that will compare two folders "core" and "custom" and return the names of the files that aren't in custom.

So far I have this code, most of which is taken form another question on stack overflow. It creates "Arrays" of the files in each folder. How can I compare them?

@echo off
setlocal enableDelayedExpansion

::build "array" of folders
set folderCnt=0
for /f "eol=: delims=" %%F in ('dir /B core') do (
  set /a folderCnt+=1
  set "folder!folderCnt!=%%F"
)

::print menu
for /l %%M in (1 1 %folderCnt%) do echo %%M - !folder%%M!
echo(

::build "array" of folders
set folderCnt=0
for /f "eol=: delims=" %%F in ('dir /B custom') do (
  set /a folderCnt+=1
  set "folder!folderCnt!=%%F"
)

::print menu
for /l %%N in (1 1 %folderCnt%) do echo %%N - !folder%%N!
echo(

pause

test.bat

解决方案

how about

echo y|xcopy /l /d core\* custom\

which should list all the files in core that are not in custom or a different version is in core?

这篇关于批处理文件比较两个文件夹退回没有一个文件夹中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆