Newbie: Shellcopy problem
[1/2] from: udo::melis::profimail::de at: 22-Feb-2002 4:00
Hello Everybody!
I have s problem:
I want to copy all files from the current directory to another, but only
if they dont exist there or they are smaller ( incomplete ) ..
Here is what i mananged to produce ..
#!/usr/local/bin/rebol -qs
REBOL [Title: "CopyBigger"]
if found? args: system/script/args [
foreach file read change-dir system/options/path [
if not dir? file [
if size? args/file < size? file or not exists? ( to-path args)/file [
write/binary (to-path args)/file read/binary file ]
]
]
]
Ive read the file section and the script section of the DOCs and i
searched the mailinglist and I did a lot of changes but nothing works
;-( If you have a solution, could you please show me how I would start
the script.
TNX
Udo
[2/2] 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