开发者

find and delete duplicates in multiple subdirectorys

开发者 https://www.devze.com 2023-04-13 08:10 出处:网络
how can I expand on the following batch code so that everything in the Tim folder is checked against all folders in the Tom directory.

how can I expand on the following batch code so that everything in the Tim folder is checked against all folders in the Tom directory.

Beter said if Tim has a file named Mytext.txt in it how can I check all and not just the top directory fond starting with C:\Tom, it may be that in tom there is a another folder with an other folder in that yet again with Mytext.txt in it.

All the code below currently dose is check the specifide directory only i would also like to check through any subdirectorys?

for /r "C:\Tim" %%f in (*) do if开发者_运维知识库 exist "C:\Tom\%%~nxf" del /s /q "C:\Tim\%%~nxf"


You nearly got it, you only need a second FOR /R loop, to search in all subdirs of TOM

for /r "c:\tim" %%I in (*) do (
  echo searching for %%~nxI
  for /r "C:\tom" %%O in (%%~nxI) do (
    if exist %%O echo found in %%O
  )
)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号