This should find empty dirs, but you might add error handling - I got a
sharing violation with the paging file:
emptyDirs := OrderedCollection new.
dirScan := [:dir |
(dir filenamesMatching: '*') do: [:fn |
fn isDirectory
ifTrue: [fn directoryContents isEmpty
ifTrue: [emptyDirs add: fn]
ifFalse: [dirScan value: fn]]]].
dirScan value: 'c:\' asFilename.
emptyDirs inspect
For filenames, compare file extension and file size. For files of the
type you want, you might keep them in a dictionary for which each entry
is keyed with a file size in bytes, and the value of each key is a
collection of files of the right type with that size. For same sized
files, compare byte by byte to see if they are duplicates. Also, if you
limit it to a portion of c:\, naturally it will be faster.
Dave
Diedert, Holger wrote:
> Hello,
>
> 1. I want to find out all empty directories on c:
>
> I am searching for a fast way to find out all directories of c:
>
> I found this:
>
> (Filename named: 'c:') directoryContentsRecursively
>
> This send me all files from c:. It took a long time:-( And I canŽt ask each
> string "isDirectory". If I select this list with: "(Filename named: x)
> isDirectory" it takes munch longer...
>
> I look at the FileBrowser but I canŽt find the right methods.
>
> Can someone help me?
>
>
> 2. I am looking for duplicate files of c:. Limited by file extensions like *.pdf
> or *.jpg
>
> Any ideas for a fast execution?
>
> Thanks in advance
>
> Holger
>
>
> --
> Holger Diedert
>
> Debeka Hauptverwaltung
> Abteilung IE/V
> Ferdinand-Sauerbruch-Str. 18
> 56058 Koblenz
>
> Telefon (0261) 498-1275
> Telefax (0261) 498-2599
>
> E-Mail
[hidden email]
> Internet www.debeka.de
>
>