China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-10 06:52
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Closed] How to find folders with the same name View 1,642 Replies 7
Original Poster Posted 2008-10-15 18:03 ·  中国 广东 佛山 电信
初级用户
Credits 21
Posts 13
Joined 2005-12-04 21:05
20-year member
UID 46489
Status Offline
There are two hard drives with a large number of movies, and folders are created with movie names inside the hard drives. There are many duplicate movies in the two hard drives. How to use batch processing to find out the duplicate ones, that is, find out the folders with the same names in the two hard drives and output them to a notepad. Thanks!

[ Last edited by HAT on 2008-10-25 at 18:26 ]
Floor 2 Posted 2008-10-16 01:36 ·  中国 广东 佛山 电信
初级用户
Credits 21
Posts 13
Joined 2005-12-04 21:05
20-year member
UID 46489
Status Offline
Floor 3 Posted 2008-10-20 04:43 ·  中国 广东 广州 海珠区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
for /f "delims=" %%i in ('dir /ad /b /s') do (
if defined "%~nxi" (
echo %%"%~nxi"%% ==== %~i >>list.txt
) else (
set ""%~nxi"=%~i"
)
)
49206C6F766520796F752067757973 54656C3A3133383238343036373837
Floor 4 Posted 2008-10-21 14:05 ·  中国 广东 深圳 罗湖区 电信
新手上路
Credits 19
Posts 13
Joined 2008-10-21 13:17
17-year member
UID 128951
Gender Male
Status Offline
Bump
Floor 5 Posted 2008-10-21 23:49 ·  中国 广东 佛山 电信
初级用户
Credits 21
Posts 13
Joined 2005-12-04 21:05
20-year member
UID 46489
Status Offline
It's really too novice, can't understand. Can you explain how to use it?
Floor 6 Posted 2008-10-22 06:21 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
For example, if your two hard drives are E and F drives under the current system, then you can do this:

for /f "delims=" %%i in ('dir /ad /b /s E:;F:') do (
if defined "%~nxi" (
echo %%"%~nxi"%% ==== %~i >>list.txt
) else (
set ""%~nxi"=%~i"
)
)

Finally, the list.txt generated in the directory where the batch file is located should be the duplicate directories, but I haven't tested it.
49206C6F766520796F752067757973 54656C3A3133383238343036373837
Floor 7 Posted 2008-10-25 16:52 ·  中国 江苏 苏州 电信
初级用户
★★
Credits 133
Posts 75
Joined 2008-08-03 01:08
18-year member
UID 122677
Gender Male
Status Offline
The game upstairs I don't understand, can you help solve it, thank you first.
if defined "%~nxi" (
echo %%"%~nxi"%% ==== %~i
Floor 8 Posted 2008-10-26 01:31 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
if defined var Check if variable var exists
Because of the non-standard characteristics of the directory name, quotes are used to close this variable name, so there is
if defined "%~nxi"
Then, if this variable exists, it means there is a duplicate, so output this duplicate folder path to list.txt
If it does not exist, set this variable
set ""%~nxi"=%~i"
49206C6F766520796F752067757973 54656C3A3133383238343036373837
Forum Jump: