33 %local dirindicator_en dirindicator_de encoding s dirfile xwait xsync xmin l_i_path;
34 %let dirindicator_en=Directory of;
35 %let dirindicator_de=Verzeichnis von;
36 %let encoding=pcoem850;
37 %let l_i_path = %sysfunc(translate(&i_path,\,/));
40 create table &o_out (filename
char(255));
42 %IF &syserr NE 0 %THEN %GOTO errexit;
44 %let xwait=%sysfunc(getoption(xwait));
45 %let xsync=%sysfunc(getoption(xsync));
46 %let xmin =%sysfunc(getoption(xmin));
48 options noxwait xsync xmin;
50 %let dirfile=%sysfunc(pathname(work))\___dir.txt;
51 filename _dirfile
"&dirfile" encoding=&encoding;
55 %IF &i_recursive %then %let s=/S;
57 %
if &g_verbose. %then %
do;
58 %put ======== OS Command Start ========;
60 %SYSEXEC(dir &s /a-d
"&l_i_path" >
"&dirfile" 2>&1);
61 %
if &sysrc. = 0 %then %put &g_note.(SASUNIT): Sysrc : 0 -> SYSEXEC SUCCESSFUL;
62 %
else %put &g_error.(SASUNIT): Sysrc : &sysrc -> An Error occured;
65 %put &g_note.(SASUNIT): SYSEXEC COMMAND IS: dir &s /a-d
"&l_i_path" >
"&dirfile";
69 infile
"&dirfile" truncover lrecl=512;
73 %put ======== OS Command End ========;
76 %SYSEXEC(dir &s /a-d
"&l_i_path" >
"&dirfile");
77 options &xwait &xsync &xmin;
79 data &o_out (keep=membername filename changed);
80 length membername dir filename $255 language $2 tstring dateformat timeformat $40;
81 retain language
"__" dir FilePos dateformat timeformat Detect_AM_PM;
82 infile _dirfile truncover;
84 if index (line,
"&dirindicator_en") or index (line, "&dirindicator_de") then do;
85 if index (line, "&dirindicator_en") then do;
86 dir = substr(line, index (line, "&dirindicator_en")+length("&dirindicator_en")+1);
89 dir = substr(line, index (line, "&dirindicator_de")+length("&dirindicator_de")+1);
92 if substr(line,1,1) ne ' ' then do;
93 * Check for presence of AM/PM in time value, because you can specify AM/PM timeformat in German Windows *;
94 if (language = "__") then do;
95 Detect_AM_PM = upcase (scan (line, 3, " "));
96 if (Detect_AM_PM in ("AM", "PM")) then do;
97 Filenamepart = scan (line,5, " ");
98 Filepos = index (line, trim(Filenamepart));
100 dateformat = "mmddyy10.";
101 timeformat = "time9.";
104 Filenamepart = scan (line,4, " ");
105 Filepos = index (line, trim(Filenamepart));
107 dateformat = "ddmmyy10.";
108 timeformat = "time5.";
111 if ("&G_DATEFORMAT." ne "_NONE_") then do;
112 dateformat = "&G_DATEFORMAT.";
113 line = tranwrd (line, "Mrz", "Mär");
115 d = inputn (scan (line,1,' '), dateformat);
116 tstring = trim (scan (line,2,' '));
117 if (Detect_AM_PM in ("AM", "PM")) then do;
118 tstring = trim (scan (line,2,' ')) !! ' ' !! trim (scan (line, 3, ' '));
120 t = inputn (tstring, timeformat);
121 changed = dhms (d, hour(t), minute(t), 0);
122 format changed datetime20.;
123 membername = translate(substr (line,FilePos),'/','\');
124 filename = translate(trim(dir),'/','\') !! '/' !! membername;