[REBOL] Re: File versions: HELP!
From: agem:crosswinds at: 6-Jul-2001 21:19
RE: [REBOL] Re: File versions: HELP!
[Mario--Cassani--icl--com] wrote:
> Hi "mage" (egam),
oh! i missed that :)
> thankyou very much, changing a bit your script will
> save my weekend!!!
>
> This was my work to compare a list of files with
> two directories...
>
snip
> 8<-----------8<-----------8<-----------8<-----------8<-----------
>
> I added the following but with no good results, how can I
> know if the parse found the string? With a separate 'find?
> The script goes wrong also when something like
>
> rem copy %1\where\file.ext d:\destination
> call other.bat %1 %2 %3 %4
>
> that should be ignored while
>
> call other.bat %1\other\path\file.txt %2 %3 %4
>
> that's ok
>
[rebol []
pdp: func [b] [probe do probe b] ;tool
print {
parse returns true if a string can
be completely parsed,
otherwise false
so you can do:}
pdp [
s: "rem copy %1\where\file.ext d:\destination"
if parse s ["rem " to end] [
"oops. a remark!"
]
]
print {
attention: you need [to end]!
otherwise there are chars left.
}
pdp [
bfile: "call other.bat %1 %2 %3 %4"
either parse bfile [thru "%1\" copy b-file to " " to end]
["file for me!" b-file] ["take it back please"]
]
pdp [
bfile: "call other.bat %1\other\path\file.txt %2 %3 %4"
either parse bfile [thru "%1\" copy b-file to " " to end]
[join "file for me: " b-file] ["take it back please"]
]
print {
note i use "%1\" for better check,
but b-file now without leading "\"..
also i use [detab read ..] if i could have tabs,
like "rem(tab)" instead of "rem ".
but parse without /all does some space/tab-conversion.
not sure about the details..
}
]
> 8<-----------8<-----------8<-----------8<-----------8<-----------
>
> path-China: %/l/
> path-Thai: %/o/
>
> ;recursive-files: function [pathSrc [file!] pathDes [file!]] [files file
> file-list] [
> recursive-files: function [pathSrc [file!]] [files file file-list] [
> files: load pathSrc
> file-list: to-block 1
> foreach file files [
> either dir? join pathSrc file [
> append file-list recursive-files join pathSrc file
> ;print pathSrc/:file
> ][
> append file-list join pathSrc file
> ; Use only .BAT scripts
> if ".bat" = find/last form file ".bat" [
> fileSource: pathSrc/:file
> bat-file: read/lines fileSource
>
> foreach bfile bat-file [
> parse bfile [thru %1 copy b-file to " "]
> if not exists? to-file pathSrc/:b-file [print join
> pathSrc/:b-file [" *** " bfile]]
> ]
> ]
> ]
> ]
> return file-list
> ]
>
quick adoption :)
> initialpath: currentpath: SS-path
> if #"/" <> last currentpath [
> append currentpath "/"
> ]
dirize currentpath ;-)