Be seen. Boost your question’s priority for more expert views and faster solutions
PROCEDURE ScanDirectory
LPARAMETERS cDirectory, cExtensions, lRelativeDirs
LOCAL nFiles, nFile, i, nRecno, cDirectory1
IF EMPTY(cDirectory)
cDirectory = SYS(5) + SYS(2003)
ENDIF
cDirectory1 = cDirectory
IF RIGHT(cDirectory1,1) <> '\'
cDirectory1 = ADDBS(cDirectory1)
ENDIF
CREATE CURSOR tmpfilenames (directory M, filename M, dir L, scanned L, size N(10), date D, selected L, order C(250))
APPEND BLANK
REPLACE directory WITH cDirectory,;
dir WITH .t.
SCAN FOR dir AND NOT scanned
cDirectory = ADDBS(ALLTRIM(tmpfilenames.directory)) + ALLTRIM(tmpfilenames.filename)
REPLACE scanned WITH .t.
nFiles = ADIR(aDirectory,cDirectory + '\*.*','D')
nRecno = RECNO()
FOR nFile = 1 TO nFiles
IF aDirectory(nFile,1) = '.' OR aDirectory(nFile,1) = '..'
LOOP
ENDIF
APPEND BLANK
IF 'D' $ aDirectory(nFile,5)
REPLACE directory WITH cDirectory,;
filename WITH aDirectory(nFile,1),;
date WITH aDirectory(nFile,3),;
dir WITH .t.
ELSE
REPLACE directory WITH cDirectory,;
filename WITH aDirectory(nFile,1),;
size WITH aDirectory(nFile,2) ,;
date WITH aDirectory(nFile,3)
ENDIF
ENDFOR
GOTO nRecno
ENDSCAN
IF lRelativeDirs
REPLACE ALL directory WITH STRTRAN(directory,cDirectory1,'')
ENDIF
REPLACE ALL order WITH PADR(LEFT(directory,125),125) + PADR(LEFT(filename,125),125)
IF EMPTY(cExtensions)
SELECT *;
FROM tmpfilenames;
ORDER BY order;
WHERE selected;
INTO CURSOR tmpfilenames
ELSE
FOR i = 1 TO OCCURS('|',cExtensions)+1
REPLACE selected WITH .T. FOR NOT dir AND ('.' + LOWER(extract(cExtensions,'|',i)) $ LOWER(filename))
ENDFOR
SELECT *;
FROM tmpfilenames;
ORDER BY order;
WHERE selected;
INTO CURSOR tmpfilenames
ENDIF
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Join the community of 500,000 technology professionals and ask your questions.