Delete name-duplicate except the newest file

English support forum

Moderators: Hacker, petermad, Stefan2, white

User avatar
pdavit
Power Member
Power Member
Posts: 1529
Joined: 2003-02-05, 21:41 UTC
Location: Kavala -> Greece -> Europe -> Earth -> Solar System -> Milky Way -> Space
Contact:

Post by *pdavit »

ghisler(Author) wrote:TC 7 will contain a new command which will select all files in the same directory, so this may help if the files and their duplicates are in different dirs. It has helped me already once. If anyone has another idea of selecting files in this situation, then it's NOW the time to suggest it, because I'm still in the phase of adding new functions.
Great news Christian!

Along to Sheepdog's suggestions (and Clo's) it should also be wise to add a tick
box or something where we could selectively activate/deactivate deletion verification.

Thanks! ;-)

PS: Even without a beta release, I believe the beta forum should start becoming
more active. We are here to aid you Christian improve the quality of your
product, save you some time and guide you with present references! ;-)
"My only reason for still using M$ Window$ as an OS is the existence of Total Commander!"
Christian Ghisler Rules!!!
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Search: *.*
Find Duplicate Files: Name [x] Size [x]
Feed to Listbox.

Output of Listbox in Details View:
X:\2KBootCD\+Tools\ cabarc.exe
X:\2KBootCD\+Tools\BLAH\ cabarc.exe
X:\2KBootCD\+Tools\BOOTDISK\ cabarc.exe
X:\2KBootCD\+Tools\Support\ cabarc.exe
Creation of a CustomColumn,
Caption: "Name & Date", Field Contents: [=tc.name] [=tc.writedate]

Choosing that Custom Column to filter with:
[Name]...[Ext]...[Name & Date]
cabarc.exe ---- cabarc 08/29/2002 08:00
cabarc.exe ---- cabarc 08/29/2002 09:00
cabarc.exe ---- cabarc 08/29/2002 10:00
cabarc.exe ---- cabarc 08/29/2002 11:00
foo.exe -------- foo 08/29/2002 08:00
foo.exe -------- foo 08/29/2002 09:00
foo.exe -------- foo 08/29/2002 10:00
foo.exe -------- foo 08/29/2002 11:00
Looks like it works to me?

Changed results, tested w/ foo.exe and cabarc.exe
click on the [name & date] column and we get the above.
Course you'd still have to manually select all the files to delete, they are sorted properly.
Last edited by Balderstrom on 2005-10-14, 12:40 UTC, edited 1 time in total.
LarsSandberg
Junior Member
Junior Member
Posts: 62
Joined: 2003-04-11, 07:46 UTC
Location: Denmark

Post by *LarsSandberg »

Looks like it works to me
Offcourse, since all 4 files have the same name: "cabarc.exe", then try the same during a bunch of sub-dirs, with many files, with some duplicates.
Voila it doesn't work as shown on png screen-dump on my ftp-server
ftp://83.93.73.168
anonymous login
Best regards
Lars
KevinMo
Member
Member
Posts: 104
Joined: 2005-03-27, 01:37 UTC

Post by *KevinMo »

Totally agree with LarsSandberg

I think the main problem is the file list cannot be sorted in groups. In other words, if we can sort these files in groups after "feed to listbox", we can sort them by name, by path, by timestamp, etc. And it won't be TC's job to to decide which files should get deleted any more. However, adding a function such as select only the first file in each group would be handy :D

Regards,
KevinMo
User avatar
majkinetor
Senior Member
Senior Member
Posts: 369
Joined: 2005-11-20, 10:36 UTC
Location: Belgrade, Serbia
Contact:

Post by *majkinetor »

With your listbox view still showing groups of names, redirect whole output to console script via %L. Your script should receive cmdXX residing in %TEMP% folder listing the same thing from listview. Now write batch script receiver that will expand each group in some new temporary text file sort them by date and prepend del to all lines except first. It's maybe an hour to write such script and test it, but you do it only once after that you have it all the time and it is accecible via TC start menu. You can even choose not to delete them, but to prepend something else, like move, or rename.

No 3party tools, works for every computer. I use this procedure all the time for various other needs. It's just matter of how good you are in batch scripting witch is by my opinion very hard to learn if you want to handle it full power, because there are many undocumented techniques on which you can inform yourself on several sities devoted to bach programming.
KevinMo
Member
Member
Posts: 104
Joined: 2005-03-27, 01:37 UTC

Post by *KevinMo »

maybe I'll try some other script if I can't manage to write a good batch file :)

But first... how to "redirect whole output to console script via %L" :oops:

Thanks in advance
User avatar
majkinetor
Senior Member
Senior Member
Posts: 369
Joined: 2005-11-20, 10:36 UTC
Location: Belgrade, Serbia
Contact:

Post by *majkinetor »

Lets say you want to do something with each file in the list. Create following batch file (only in XP):

FILE: test.bat

Code: Select all

for /F "delims=" %%i in (%1) do call :func %%i
goto :EOF


:func

  ::put some code here, for instance
  ren %1 "%~1.bak"   
goto :EOF

How to install:
Open Start->Change Start Menu
Add new item:
Command = <path>\test.bat
Parameters = %L


This way TC will execute: test.bat "file list"

Thats it.
You can even manage not to see black command prompt window jumping.
You can either create shortcut to test.bat and set start mode to minimized, or you can download 30K freeware console app GuiBox (www.simtel.net) which can make sweet Windows directly from console and hide console itself:

Code: Select all

   ::Hide console
   GuiBox /H0   

   ::Show batch script from the tray (this is cool) and fly away after 4 seconds
   GuiBox thinger - "Executing test.bat" 4
Extrapolate.
If you need any more help just let me know. If you have further problems writing this script I will find time to write it for you, but my suggestion is to do it yourself.[/code]
User avatar
majkinetor
Senior Member
Senior Member
Posts: 369
Joined: 2005-11-20, 10:36 UTC
Location: Belgrade, Serbia
Contact:

Post by *majkinetor »

I forgot to tell you that you must select all files before starting script.
KevinMo
Member
Member
Posts: 104
Joined: 2005-03-27, 01:37 UTC

Post by *KevinMo »

Thanks for your reply!

However... One more question... How could a batch file know which files are in one group?

For example, here are five files. 001,003,005 are identical; 002,004 are identical.

Code: Select all

C:\test\
 |new2\
  |001.txt
  |004.txt
 |new1\
  |002.txt
  |003.txt
  |005.txt
After dup-search -> feed to listbox -> select all -> pass to batch file with %L, the listfile created in %TEMP% will looks like

Code: Select all

c:\test\new1\003.txt
c:\test\new1\005.txt
c:\test\new2\001.txt
c:\test\new1\002.txt
c:\test\new2\004.txt
How could it possible to know 001.txt is the same as 005.txt or 002.txt?
PS: they might have the same size ...
User avatar
majkinetor
Senior Member
Senior Member
Posts: 369
Joined: 2005-11-20, 10:36 UTC
Location: Belgrade, Serbia
Contact:

Post by *majkinetor »

Eatch group must have something in common since this was initial job, to find all files that share something - name, size...

your PS tip is correct. Each group will have files of the same size. Your job is to iterate through all of them and separate size groups.

see for /? and %~zI modifier at the end of the help



Don't hesistate to ask.
You have plenty of advanced batch script examples shiping with GuiBox. You can take a look, just to see posibilities.
KevinMo
Member
Member
Posts: 104
Joined: 2005-03-27, 01:37 UTC

Post by *KevinMo »

Actually, I mean maybe all of them have the same size. Then I'll have to compare some of them, which is the job TC just did...

Really really thank you very much for your kindness. But I think I would give up on this subject :oops: Download another freeware or shareware might be easier than sorting and comparing these files in batch script.

PS: guibox IS GREAT. Thanks again ~
User avatar
majkinetor
Senior Member
Senior Member
Posts: 369
Joined: 2005-11-20, 10:36 UTC
Location: Belgrade, Serbia
Contact:

Post by *majkinetor »

you welcome.

You are somewhat right, 3rd party tool can solve your problem now. It might not save you in the future.
You are not doing TC job because TC found those files for you, you just need to split the groups.

However, consider goodies from learning batch script. There are 2 other ways of scripting in WinOS. JavaScript and VBScript each depending on Windows scripting host to be started. On many computers it is disabled because of security reasons, but I found that there are not so many admins who will disable console. It's just not right. So, not knowing BATCH is like not knowing BASH or some other linux equivalent shell language. It is possible the worst language ever written, but we have no choice here. It is the shell's language in WinOS. You can do amazing things with just several lines of code on every computer you come cross.


Anyway, you are experienced user yourself, I guess you know by now what are your priorities. If you find thing to be cumbersome or something, then don't do it. Just be aware of possibilities for your own sake, and for the sake of your own security.
UserJo
New Member
New Member
Posts: 1
Joined: 2006-09-21, 22:34 UTC

Post by *UserJo »

Hi Kevin Mo,

I hope you are staying tuned to this topic!?
KevinMo wrote: How could a batch file know which files are in one group?
I just invented a way where not only a batch file but also the regular list view of tc will know about groups of content identical files (with different file names). Even if I've never tried I bet/promise by the heart of my mother :twisted: that it will work:

1. Content identical files with different file names will have the same checksum.

2. Create a custom column "sort" with the field contents

[=<plugin>.md5] [=tc.writedate]

where <plugin> is a placeholder for a content plugin that calculates md5 checksum for a file. Other checksums like sha will also be fine.

BTW: Does anyone know a suitable plugin for this task?

3. Sort the find duplicate file result window by the column "sort".

Good luck

UserJo
User avatar
XPEHOPE3KA
Power Member
Power Member
Posts: 854
Joined: 2006-03-03, 18:23 UTC
Location: Saint-Petersburg, Russia

Post by *XPEHOPE3KA »

BTW: Does anyone know a suitable plugin for this task?
Haha! That is the main question. I've heard someone was intending to write it, but no news about that... :(
F6, Enter, Tab, F6, Enter, Tab, F6, Enter, Tab... - I like to move IT, move IT!..
User avatar
XPEHOPE3KA
Power Member
Power Member
Posts: 854
Joined: 2006-03-03, 18:23 UTC
Location: Saint-Petersburg, Russia

Post by *XPEHOPE3KA »

Now there is a solution: http://ghisler.ch/board/viewtopic.php?p=97307#97307

Use shelldetails plugin with that.
F6, Enter, Tab, F6, Enter, Tab, F6, Enter, Tab... - I like to move IT, move IT!..
Post Reply