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-07-15 00:19
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » (Closed) A question about deleting files with the same size and type! View 3,847 Replies 25
Original Poster Posted 2006-10-26 05:25 ·  中国 上海 浦东新区 电信
初级用户
Credits 30
Posts 14
Joined 2006-10-26 04:43
19-year member
UID 68307
Gender Male
Status Offline
For example: If there are the following files under a folder (the folder name is known as asd, and there are many files in the folder, which cannot be listed manually):

Volume in drive D is WINDOWS
Volume Serial Number is E42C-4D75

Directory of D:\asd\asd

2006-10-24 17:47 <DIR> ..
2006-10-24 17:47 <DIR> .
2006-10-20 11:47 1,226 tftp.txt
2006-10-16 15:51 2,306 ftp1 server.txt
2006-10-16 15:51 2,306 ftp1.txt
2006-10-16 15:51 2,306 ftp2.txt
2006-10-16 15:51 2,306 ftp3.txt
2006-10-16 15:51 2,306 ftp1.rar
2006-10-16 15:51 2,306 ftp1.log
2006-10-16 15:51 2,306 ftp2 server.txt
2006-10-20 14:30 10,752 ftp1.doc
9 File(s) 28,120 bytes
2 Dir(s) 12,679,954,432 bytes free

How to delete files with the same size and the same file type???
(That is to say, the three files ftp2.txt, ftp3.txt, and ftp2 server.txt need to be deleted,)

[ Last edited by WinXYhappy on 2006-10-27 at 05:23 AM ]
Floor 2 Posted 2006-10-26 07:58 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
I remember there was a small thing that could be directly deleted, est posted about it
Floor 3 Posted 2006-10-26 09:05 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

Are you going to delete all files with the same size and type, or keep one and delete the others?
Floor 4 Posted 2006-10-26 10:13 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
```
for /f "delims=" %a in ('dir /a ^| find "2,306"') do @del %a
```

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 5 Posted 2006-10-26 20:16 ·  中国 上海 浦东新区 电信
初级用户
Credits 30
Posts 14
Joined 2006-10-26 04:43
19-year member
UID 68307
Gender Male
Status Offline
Originally posted by lxmxn at 2006-10-26 09:05 AM:

The owner wants to delete all files with the same size and type, or keep one and delete the others?


Keep one. Delete other files that have the same size "and" also the same type as this one.
Floor 6 Posted 2006-10-26 20:29 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 7 Posted 2006-10-26 20:39 ·  中国 上海 浦东新区 电信
初级用户
Credits 30
Posts 14
Joined 2006-10-26 04:43
19-year member
UID 68307
Gender Male
Status Offline
Originally posted by electronixtar at 2006-10-26 10:13 AM:

for /f "delims=" %a in ('dir /a ^| find "2,306"') do @echo %a


After confirming it is correct, change echo %a to del %a


What I mean is: First, we don't know how many files are in the folder (because there are too many to list manually), and we don't know the size of the files. We only know the name and path of the folder. The above is a simple example. Actually, there are many files (mainly.doc,.xls files, too many to list here), and there are many files with similar names and the same size that are actually the same. So we need to delete them to save space.
Hope electronixtar can help improve it again. By the way, can batch processing achieve fuzzy matching, for example: delete (temp1.doc, temp2.doc, temp3.doc, temp4.doc~~) and keep temp1.doc by keeping temp2~~.doc.
Note: temp is just a placeholder for the files to be processed.
Floor 8 Posted 2006-10-26 20:58 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
It's very simple, copy out temp1.doc and delete the folder.

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 9 Posted 2006-10-26 23:56 ·  中国 上海 浦东新区 电信
初级用户
Credits 30
Posts 14
Joined 2006-10-26 04:43
19-year member
UID 68307
Gender Male
Status Offline
Originally posted by electronixtar at 2006-10-26 08:58 PM:
It's very simple. Copy out temp1.doc and delete the folder;

So depressed!
But I guess that's how scholarship is!

What I mean is I know the name of this folder, but I don't know the names of the files in the folder (so the above temp is just a placeholder,...... a placeholder. Not actual). Because there are too many files, I can't list them one by one.
For example for example for example for example:
There are temp1.doc, temp2.doc, temp3.doc~~
tmp1.xls, tmp2.xls, tmp3.xls~~
study1.txt, study2.txt~~
***1.gif, ***2.gif~~~~

So the function of dir also needs to be implemented in del.bat, and also find (***) then perform the function of deleting duplicate files. I don't know if electronixtar understands. Oh my expression ability, so...... hahaha. electronixtar needs to carefully figure out my meaning. Thanks.
Floor 10 Posted 2006-10-27 00:09 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
If this operation is only done once, you can complete it through Windows' search function, heh heh~

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 11 Posted 2006-10-27 00:11 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline

Hahaha, I spent the whole morning looking at everything related to deletion. It doesn't seem to fit my conditions.

That was he200377 who misread it. I also thought it was a really stubborn duplicate file when I saw the title of the original poster, but it turned out to be a duplicate file. Hehe

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 12 Posted 2006-10-27 01:10 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 13 Posted 2006-10-27 01:15 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
If you want to delete duplicate file contents, it's not easy.
Floor 14 Posted 2006-10-27 02:46 ·  中国 上海 浦东新区 电信
初级用户
Credits 30
Posts 14
Joined 2006-10-26 04:43
19-year member
UID 68307
Gender Male
Status Offline
No, I need to repeat it many times. There are too many, so I want to write a batch script to do it. I'm not very capable myself, so I'm here to ask for help from all the experts. Hahaha
Floor 15 Posted 2006-10-27 02:52 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Remember a software called: Duplicate File Finder

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Forum Jump: