Folder operations in BaseX

Monday, 13 February 2017 · 3 messages · last reply 15 Feb 2017
NB
Nanday, Bhushan13 Feb 2017 22:19 #
Hi All, Hope everyone is doing good. I am currently trying to copy an entire folder from the source location to a destination location. I have tried rename but its too expensive from time response stand point when the schema size is too large. To go around the problem I am trying to run the xquery using db:store (). But db:store doesn’t seem to work on folders. So I am wondering if there is any other efficient way ( apart from rename and db:store) which will work on the folder. I need to copy the entire folder from source location to destination and it may have a hierarchy of sub-folders in it. Any help on that is really appreciated! Thanks, Bhushan
CG
Christian Grün13 Feb 2017 22:46 #
Hi Bhushan,
Quoted text · Nanday, Bhushan · 2 lines
> Hope everyone is doing good. I am currently trying to copy an entire > folder from the source location to a destination location.
How did you proceed so far? Regards, Christian
CG
Christian Grün15 Feb 2017 11:42 #
Hi Bhushan (cc to the list), So you are exclusively working with binary resources, right? In that case, a query like the following one can be used:
  let $db := 'db'
  let $src-path := 'src/'
  let $trg-path := 'trg/'
  for $src in db:list($db, $src-path)
  let $trg := $trg-path || substring-after($src, $src-path)
  return db:store($db, $trg, db:retrieve($db, $src))
I have added a slightly revised version of this query in our Wiki [1]. Hope this helps, Christian [1] http://docs.basex.org/wiki/Database_Module#db:store
Quoted text · Bhushan · 22 lines
On Wed, Feb 15, 2017 at 6:11 AM, Nanday, Bhushan <bhushan.nanday at sap.com> wrote: > Hi Christian, > > Thanks for reaching out. I am currently trying to use the db:store(source, destination, file) in an xqeury. This approach works well when the source is a file but doesn’t work when the source is a folder. I need something that will move/copy and entire folder and not just a file. > > > > > > On 2/13/17, 1:46 PM, "Christian Grün" <christian.gruen at gmail.com> wrote: > > Hi Bhushan, > > > Hope everyone is doing good. I am currently trying to copy an entire > > folder from the source location to a destination location. > > How did you proceed so far? > > Regards, > Christian > >

⚡Generated with XQuery