Bonjour,
Voici le script suivant:
- Actuellement, je test la boucle FOR IN DO pour l'argumet -chk. Les tests fonctionnent uniquement si le fichier index.txt et/ou index.diff est à la racine du disque. Je ne parviens pas à écrire le test qui pourrait envisager que les deux fichiers se trouvent dans un répertoire ou bien un sous répertoire.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 @ECHO OFF REM.-- Version history -- REM X.X.X YYYYMMDD Author Description SET version=1.2.1 &:20150916 olivier initial version SET version=%version: =% REM.-- Set the default color of the command prompt -- COLOR 07 REM.-- Set the title -- SET title=%~nx0 %version% TITLE %title% REM.-- Set default variables -- SET tmp_i=index.txt.tmp SET def_i=index.txt SET tmp_di=index.diff.tmp SET def_di=index.diff SET findstr=findstr.exe SET diff=diff.exe REM.-- Do something useful -- SET "args=-v -chk -gen -cmp -dpl" SET "drvs=a b c d e f g h i j k l m n o p q r s t u v w x y z" IF [%1]==[] ( GOTO:-h ) IF "%1"=="-v" ( IF NOT [%2]==[] ( GOTO:-h ) GOTO:-v ) FOR %%a IN (%drvs%) DO ( IF "%1"=="-chk" ( IF "%2"=="%%a:\%def_i%" ( GOTO:-chk ) IF "%2"=="%%a:\%def_di%" ( GOTO:-chk ) ) ) GOTO:-h EXIT /b :-chk ECHO. IF EXIST %2 ( ECHO %2 : file found ) ELSE ( ECHO %2 : file not found ) GOTO:EOF :-gen ECHO GEN GOTO:EOF :-cmp ECHO CMP GOTO:EOF :-dpl ECHO DPL GOTO:EOF :-v ECHO %version% GOTO:EOF :-h ECHO usage: %~nx0 [ -v ] ECHO %~nx0 [ -chk ^| -gen ^| -cmp ^| -dpl ] index.txt or .diff ECHO. ECHO -v : display version number and exit ECHO -chk : check if file exist ECHO -gen : generate output file ECHO -cmp : compare output file ECHO -dpl : display output file GOTO:EOF
Pourriez-vous me donner un petit coup de main s'il vous plaît ? Merci
Partager