Make backup of all your valuable REBOL files

12 views
Skip to first unread message

Petri Keckman

unread,
Jul 18, 2023, 12:30:46 AM7/18/23
to REBOL
So you want to make backup of all your valuable REBOL files? Here's how I did it! From disk /E/ to USB-drive /F/ :)



makeback.jpg

pd

unread,
Jul 19, 2023, 9:39:16 PM7/19/23
to REBOL
Hello Petri,

Pretty interesting code, another option would be:

REBOL [Author: Pep Diz]

lmap: function [l [series!] f ] [ r: copy [] foreach e l [ append r f e ] r]
lfilter: function [l [series!] f ] [ r: copy [] foreach e l [ if f e [append r e ]] r]
ldicotomy: func [l [series!] f /local r1 r2 e] [ r1: copy [] r2: copy [] foreach e l [ either f e [append r1 e ] [append r2 e]] reduce [r1 r2] ]

rebolfile?: func [f /local p] [(none <> p: attempt [load/header f]) and  block? p]
excludeDir?: func [d xpat] [ any lmap xpat func [x] [none <> find d x]]

backupRfiles: func [fulldir fulldestdir /xdir xdirs [series!] /local LL r1 r2 dirs fics] [
    LL: lmap reduce [fulldir] func [x] [read x]
    set [r1 r2] ldicotomy LL func [x] [dir? x]
    if xdir [ r1: copy lfilter r1 func [x] [not excludeDir? x xdirs] ]
    dirs: lmap r1 func [x] [rejoin [fulldir x]]
    fics: lmap r2 func [x] [rejoin [fulldir x]]
    lmap dirs func [x] [either xdir [backupRfiles/xdir x fulldestdir xdirs] [backupRfiles x fulldestdir]]
    lmap lfilter fics :rebolfile? func [x] [write/binary rejoin [fulldestdir next find/last x "/"] read/binary x]
]

backupRfiles/xdir %/E/ %/F/ ["/E/$RECYCLE.BIN/" "/E/System Volume Information/"]

Regards
Reply all
Reply to author
Forward
0 new messages