Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Newbie: Shellcopy problem

From: atruter:hih:au at: 22-Feb-2002 16:23

<SNIP>I want to copy all files from the current directory to another, but only . . .</SNIP> Probably overkill for what you want, but the following function synchronises a child [or cache] directory with a parent. I typically use it like "cache-dir %/f/camera %/c/cache", could be easily extended to sync across network if desired . . . cache-dir: func [pdir cdir /local pfile cfile] [ ; Ensure dirs are valid if not exists? pdir [ print reform ["Parent" pdir "not found!"] halt ] if not exists? cdir [ print reform ["Cache" cdir "not found!"] halt ] ; Read parent dir and update cache dir if checksum differs or file not exists foreach f read pdir [ pfile: join pdir f cfile: join cdir f either exists? cfile [ if (checksum read/binary pfile) <> (checksum read/binary cfile) [ write/binary cfile read/binary pfile ] ][ write/binary cfile read/binary pfile ] ] ; Read cache dir and remove if not present in parent dir foreach f read cdir [ pfile: join pdir f cfile: join cdir f if not exists? pfile [ delete cfile ] ] ] Regards, Ashley