How to quickly find added / removed files?

前端 未结 10 2609
情深已故
情深已故 2020-12-25 08:28

I am writing a little program that creates an index of all files on my directories. It basically iterates over each file on the disk and stores it into a searchable database

10条回答
  •  时光取名叫无心
    2020-12-25 08:58

    Can you jump out of java.

    You could simply use

    dir /b /s /on M:\tests\  
    

    the /on sorts by name

    if you pipe that out to out.txt

    Then do a diff to the last time you ran this file either in Java or in a batch file. Something like this in Dos. You'd need to get a diff tool, either diff in cygwin or the excellent http://gnuwin32.sourceforge.net/packages/diffutils.htm

    dir /b /s /on m:\tests >new.txt
    diff new.txt archive.txt >diffoutput.txt
    del archive.txt
    ren new.txt archive.txt
    

    Obviously you could use a java diff class as well but I think the thing to accept is that a shell command is nearly always going to beat Java at a file list operation.

提交回复
热议问题