File versions: HELP!
[1/8] from: mario::cassani::icl::com at: 6-Jul-2001 10:09
Hi all,
I'm doing a very boring work with M$ SourceSafe and a
couple of installation CDs.
The two CDs contain:
1 - Program v1.1 installation for Thailand
2 - Program v1.2 *update* for Thailand
The program runs on mixed system with DOS, OS/2 and NT
so everything is installed copying the directory tree on the
destination PCs and running the .BAT files.
Under SourceSafe I have the Program v1.3 for both
Thailand and China and the .exe files are suffixed this way:
myprog1_thai.exe
myprog1_china.exe
myprog2_thai.exe
myprog2_china.exe
...
What I am actually manually doing is: open all the
batch (.bat, .cmd) files in the directory tree and look for:
copy %1/path/filename.ext %2/path/filename.ext
^^^^^^^^^^^^^^^^^^^^
isql %1/path/filename.ext parm1 parm2...
^^^^^^^^^^^^^^^^^^^^
checking if all the files are in the tree (with or
without the "_thai" suffix) AND VICEVERSA!!!
Can anyone help me with a script to check if files are
the same (looking date and/or size)? I have no time to write
and test my own and I am very weak with 'parse.
Thankyou and best regards
Mario
PS Don't waste your time if you cannot write it *now*:
I need this program only today, this evening I must send
the v1.3 CD to the customer...
============================================================
Mario Cassani
PGP Key fingerprint: 9929 74CF 62E9 A7A4 60D6 05DC 8034 F354
[2/8] from: arolls:bigpond:au at: 6-Jul-2001 22:00
Ok, from my understanding of your comments below;
- you have two cd's
- you want to go through the whole directory
structure of each cd
- for each .bat/.cmd file in the cd's, you would
like to look inside
- if you find a copy/isql command, you want to
check that the filenames supplied as arguments
actually exist on the cd ?
- if you are copying a _thai file, in one of the
copy commands, would you want to check that
the destination is also a _thai file as well?
- should the filename for the next isql command
also be _thai as well?
- will it be the same for _china as well?
- and same again except no _thai/china at all? ie. myprog.exe
- you want to report all discrepancies from the
above rules?
more comments below
> Hi all,
> I'm doing a very boring work with M$ SourceSafe and a
<<quoted lines omitted: 23>>
> the same (looking date and/or size)? I have no time to write
> and test my own and I am very weak with 'parse.
size? %file.bat
get in info? %file.bat 'date
> Mario Cassani
If you quickly respond I can help more.
Anton.
[3/8] from: mario:cassani:icl at: 6-Jul-2001 13:21
At first thankyou very much, this last minute check is a real PITA...
OK> - you have two cd's
OK> - you want to go through the whole directory
> structure of each cd
>
OK> - for each .bat/.cmd file in the cd's, you would
> like to look inside
>
> - if you find a copy/isql command, you want to
> check that the filenames supplied as arguments
> actually exist on the cd ?
not necessarily copy/isql but sure %1\something.ext
where %1 has to be substituted with a fixed string.
In other words:
; CD ROM
CD-path: /r/installation/data
; SourceSafe local checkout
SS-path: /d/customer1/data
either exists? CD-path/something.ext [
;compare with SS-path/something.ext
is-common? CD-path/something.ext SS-path/something.ext
;compare with SS-path/something_thai.ext
is-thai? CD-path/something.ext SS-path/something_thai.ext
;compare with SS-path/something_china.ext
is-china? CD-path/something.ext SS-path/something_china.ext
...
] [
if exists? SS-path/something.ext [
print join "Missing " CD-path/something.ext
]
]
> - if you are copying a _thai file, in one of the
> copy commands, would you want to check that
<<quoted lines omitted: 3>>
> - will it be the same for _china as well?
> - and same again except no _thai/china at all? ie. myprog.exe
See above, the CD files don't have _thai/_china in
their names
YES> - you want to report all discrepancies from the
> above rules?
>
> If you quickly respond I can help more.
As quick as possible, I am scripting too...
Read you soon
Mario
[4/8] from: agem:crosswinds at: 6-Jul-2001 16:58
RE: [REBOL] Re: File versions: HELP!
Hi Mario!
[rebol []
{
could this give tips?
change the output in 'mutants? ..
}
;libs below, remember [do main] at end..
main: [
;---prepare test
write %test_thai.txt {Hello Thais!}
write %test.txt {Hello Thais!}
; bat-contents: read/lines %...
bat-content: {
copy %1/path/filename.ext %2/path/filename.ext
isql %1/path/filename.ext parm1 parm2...
copy %1/test.txt parm1 parm2...
}
??? bat-content: parse/all bat-content "^/"
;---main main
log: copy ""
emit: func [s] [repend log s]
; CD ROM
CD-path: %./
; SourceSafe local checkout
SS-path: %/d/customer1/data/
;---get directories
set [cd-files cd-dirs]
find-files-deep/drop-dir CD-path true true
? cd-files
set [ss-files ss-dirs]
find-files-deep/drop-dir CD-path true true
? ss-files
mutants?: func [file] [
emit ["^/" mold file]
either not find ss-files file [
emit [" not on ss^/"]
] [emit " ok^/"]
foreach app [%_thai %_china] [
??? file-i18n:
head insert find/last copy file %. app
emit ["^-" mold file-i18n]
either not find cd-files file-i18n [
emit [" not on cd^/"]
] [emit " ok^/"]
]
append log "^/"
]
foreach line bat-content [
print "---"
? line
if probe parse/all line [
thru "%1/" copy file to " " to end
] [
? file
mutants? to file! file
]
]
probe head cd-files
print ["log:^/" log]
]
;lib
???: func ['word value] [print [
mold :word mold type? :value ":" mold :value]
word :value]
;---read dirs func
find-files-deep: func [
"returns [files dirs]"
dir
file-accepted?
"func which checks if you like this file"
dir-accepted?
"func which checks if you like this dir"
/drop-dir "remove base-dir-name from files"
/insert-dirs "insert dirs in file-block too"
/stars "show stars to show we are living"
/local files dirs file take
] [
max-dirs: 512 ;hard break on recursive links..
files: make block! max-dirs * 16
dirs: make block! max-dirs
append dirs dir ;yes [reduce[dir]] works too :)
foreach dir dirs [
if max-dirs < length? dirs [
make error! rejoin [
{to many dirs? > " max-dirs " !
recursive links somewhere?}
]
]
if insert-dirs [append files dir]
foreach file sort read dir [
file: join dir file
if drop-dir [file: skip file length? dir]
if stars [prin "*"] ; are we alive?
any [
if dir? file [
; allows check to be 'true
take: dir-accepted? file
if take [
append dirs file
true
]]
if file? file [
; allows check to be 'true
take: file-accepted? file
if take [append files file] true
]
make error! join {interesting kind of file..: } mold file
]
]
]
reduce [files head dirs]
]
;go
do main
]
[Mario--Cassani--icl--com] wrote:
[5/8] from: mario:cassani:icl at: 6-Jul-2001 16:47
Hi "mage" (egam),
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...
8<-----------8<-----------8<-----------8<-----------8<-----------
REBOL [
]
CD-path: %/d/Ufficio/mo_CD/
SS-path: %/d/Ufficio/mo_SS/
locales: ["_china." "_thai." "_ch." "_th."]
verificare: read/lines %EVERY-List.txt
; *** MAIN ***
if exists? %missing_on_cd.txt [delete %missing_on_cd.txt]
foreach vfile verificare [
output-tail: ""
vfile-size: join " [" [size? SS-path/:vfile "]"]
foreach locale locales [
if find vfile locale [
if not exists? to-file vfile [write/append %missing_on_cd.txt join
vfile [vfile-size newline]]
output-tail: join " <<- " vfile
replace vfile locale "."
break
]
]
if not exists? to-file vfile [write/append %missing_on_cd.txt join vfile
[vfile-size output-tail newline]]
]
halt
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
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
]
initialpath: currentpath: SS-path
if #"/" <> last currentpath [
append currentpath "/"
]
initialpath: currentpath
file-list: recursive-files currentpath
halt
8<-----------8<-----------8<-----------8<-----------8<-----------
Must finish the CD now...
Happy weekend to you all too
Mario
[6/8] from: arolls:bigpond:au at: 7-Jul-2001 2:56
> See above, the CD files don't have _thai/_china in
> their names
So you have one cd that contains only thai translations
and another cd that contains only china translations.
They are both kept on your harddisk, but with _thai and
_china in the filenames. Also on your harddisk is the
filename without any _thai/china.
Is that correct?
Can I assume that ALL the files are in the right
places on your harddisk, in the SS directory tree?
Anton.
[7/8] 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
<<quoted lines omitted: 5>>
> 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/
<<quoted lines omitted: 24>>
> return file-list
> ]
quick adoption :)
> initialpath: currentpath: SS-path
> if #"/" <> last currentpath [
> append currentpath "/"
> ]
dirize currentpath ;-)
[8/8] from: mario:cassani:icl at: 9-Jul-2001 9:21
Hi Anton,
I had to finish the CD earlier than your mail was
sent to me.
Thankyou for your support.
I think that, anyway it's interesting to finish
this REBOL work because this won't be the last CD my
company is going to make ;)
> > See above, the CD files don't have _thai/_china in
> > their names
<<quoted lines omitted: 4>>
> filename without any _thai/china.
> Is that correct?
There are files without _thai or _china suffix that
are used as common files and files with those suffixes that
must be copied on the chinese xor thai CD without suffix:
Filename Chinese CD name Thai CD Name
============== ================== ================
common.exe common.exe common.exe
abc_china.exe abc.exe ---
abc_thai.exe --- abc.exe
> Can I assume that ALL the files are in the right
> places on your harddisk, in the SS directory tree?
Yes, *now* you can ;)
I received a couple of help/scripts by [agem--crosswinds--net]
check for them on the ML archive.
Thanks again to both of you
Mario
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted