From: Andreas K. <and...@ac...> - 2007-08-01 21:14:03
|
Two packages enabling us to write multi-file operations without having to redo globs and foreach loops over and over again. A core package which provides this functionality as objects, and a package which provides the same as a single command (with a standard singleton object underneath). Example: fileutil::multi move the * from /sources to /scratch except for *.html More structure: fileutil::multi \ move \ the * \ from /sources \ to /scratch \ except \ for *.html Or, less readable, still valid fileutil::multi \ to /scratch \ from /sources \ move \ exclude *.html \ the * The first package which had this type of specification was 'treeql', also in Tcllib, to select nodes in a tree based on relationships and attributes. q query root children get data The interpreter mechanism underlying 'treeql's implementation was generalized a bit and put into its own module and package, 'wip', the 'word interpreter'. 'fileutil::multi' is the first user of this re-packaged system. Ideas for fileutil::multi I haven't done yet: * recursive operation * change file attributes, like permissions * extract/save/ the set of files the last command operated on. * inject/load a set of files to operate on A multi-rename like 'rename *.c *.cc' would be interesting, however I am not sure yet how to specify that (the example to the left would semi-require to parse the glob pattern). OTOH, the example is only a change of the file extension, and that we should be able to specify and do. Hm ... fileutil::multi \ replace_extension_of the *.c in /wherever except for foo* with CC -- Andreas Kupries <and...@Ac...> Developer @ http://www.ActiveState.com Tel: +1 778-786-1122 |