Skip to main content

Batch File Operations

4 replies [Last post]
dgriffit
Offline
Joined: 2004-10-13
Points: 0

One thing I've been hoping for is a standard utility library which would allow the definition of file sets (via regexes, recursive traversal of directories, inclusion/exclusion, etc.) and operations on those sets of files (delete, move, copy, all the usual suspects). This isn't rocket science, and is the sort of thing that has to be reinvented every time someone needs to do any sort of scripting via Java.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
zander
Offline
Joined: 2003-06-13
Points: 0

> This isn't rocket science

No it isn't, its actually 5 lines of code. I'm not sure how much easier it can be made... Did you notice the FileFilter class and interface?

dgriffit
Offline
Joined: 2004-10-13
Points: 0

FileFilters are about half the battle for defining file sets as I've described. There also needs to be support for union/intersection/difference of file sets, and defining file sets from directories(recursive or not). More important to what I was talking about were the batch operations. Again, not rocket science but tedious to do repeatedly, and error-prone in more complicated cases.

mattinger
Offline
Joined: 2004-07-01
Points: 0

Wouldn't it be nice if the folks at Apache would take the notion of Path like structures in Ant, and abstract it out into a seperate library, independent of ANT itself? It seems to me like their functionality is exactly what you want.

dgriffit
Offline
Joined: 2004-10-13
Points: 0

Correct. I even began an attempt to do that myself, but I'm afraid those parts of Ant were not as well factored as they might be back when I did it. I do think it's a reasonable bit of functionality to have in the core libraries, but a well-structured Apache library would suit me just fine.