![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-10 05:51 |
47,811 topics / 349,897 posts / today 2 new / 48,255 members |
| DOS批处理 & 脚本技术(批处理室) » [Closed] How to find folders with the same name |
| Printable Version 1,641 / 7 |
| Floor1 hjxk | Posted 2008-10-15 18:03 |
| 初级用户 Posts 13 Credits 21 | |
|
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 ] |
|
| Floor2 hjxk | Posted 2008-10-16 01:36 |
| 初级用户 Posts 13 Credits 21 | |
| Floor3 everest79 | Posted 2008-10-20 04:43 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
for /f "delims=" %%i in ('dir /ad /b /s') do (
if defined "%~nxi" ( echo %%"%~nxi"%% ==== %~i >>list.txt ) else ( set ""%~nxi"=%~i" ) ) |
|
| Floor4 liumangshiwo | Posted 2008-10-21 14:05 |
| 新手上路 Posts 13 Credits 19 | |
|
Bump
|
|
| Floor5 hjxk | Posted 2008-10-21 23:49 |
| 初级用户 Posts 13 Credits 21 | |
|
It's really too novice, can't understand. Can you explain how to use it?
|
|
| Floor6 everest79 | Posted 2008-10-22 06:21 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
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. |
|
| Floor7 slw218856 | Posted 2008-10-25 16:52 |
| 初级用户 Posts 75 Credits 133 | |
|
The game upstairs I don't understand, can you help solve it, thank you first.
if defined "%~nxi" ( echo %%"%~nxi"%% ==== %~i |
|
| Floor8 everest79 | Posted 2008-10-26 01:31 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
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" |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |