Hi Alex,
So, I ended up doing this:
I would have done it similar:
let $target := 'D:\myHardDriveDirectory' for $doc in db:open('myDB', 'myCollection') let $path := $target || db:path($doc) return ( file:create-dir(file:parent($path)), file:write($path, $doc) )
db:export('myDB/myCollection', 'D:\myHardDriveDirectory')
I'll think about your suggestion. As the database argument of all other db functions only contains the name of database, I am a bit hesitant to change this. For now, I have added the above XQuery snippet to the documentation [1]
I had also set up Webdav to try the quick drag-and-drop way, but unfortunately it has several bugs and had to stop using it.
WebDAV should be slower as other operations, because each file is requested one by one, but it should work as well. Unfortunately, however, many of the WebDAV clients use different ways to address WebDAV server. Which one did you use?
Bonus question: Is there a way to do the reverse operation with some function/command?
Once again, for now, I recommend you to use XQuery for that [2]:
let $source := '/home/john/xml/source' for $file in file:list($source, true()) let $path := $source || $file where not(file:is-dir($path)) return db:replace('db', $file, doc($path))
Hope this helps, Christian
[1] http://docs.basex.org/wiki/Database_Module#db:export [2] http://docs.basex.org/wiki/Database_Module#db:replace