include_once('/home/rwmech/public_html/robsprogrammingjunk/geshi/geshi.php');
$source = <<
loFSO=CREATEOBJECT('Scripting.FileSystemObject')
lsDrive=SYS(5)
loFolders=loFSO.GetFolder(lsDrive+'\\\somefolder')
FOR EACH loSomeFolder IN loFolders.Subfolders
IF !FILE(lsDrive+'\\\somefolder\\\'+ALLT(loSomeFolder.NAME))
WAIT WINDOW 'Checking '+ lsDrive+'\\\somefolder\\\'+ALLT(loSomeFolder.NAME) NOWAIT
FOR EACH loFile IN loSomeFolder.FILES
* DO SOMEHTING WITH THE FILE
* lsDrive+'\\\somefolder\\\'+ allt(loSomeFolder.Name)+'\\\'+allt(loFile.Name)
ENDFOR
ENDIF
ENDFOR
RELEASE loFolders
RELEASE loFile
RELEASE loFSO
WAIT CLEAR
END;
$geshi = new GeSHi($source, 'visualfoxpro');
$geshi->set_header_type(GESHI_HEADER_DIV);
$geshi->set_overall_style('font-family: Courier New , Courier, Monospace; font-size: 8pt; word-wrap:break-word;');
$geshi->set_comments_style(1, 'color: #006600;');
$geshi->set_comments_style('MULTI', 'color: #006600;');
$geshi->set_header_content('Code Example © Robert Mech. May be used freely as long as credit is given to the source.');
$geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;');
$geshi->set_footer_content('If you use this code, please make a comment on the blog!');
$geshi->set_footer_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-weight: bold; background-color: #f0f0ff; border-top: 1px solid #d0d0d0; padding: 2px;');
echo $geshi->parse_code();
?>
4 comments:
Very well code, but it is not recursive, only read the files in one subfolder from the source, and how would do if had many subfolder in the source?
I wrote that code in '06. Looking at it though it doesnt seem too hard to break those out into functions and call it recursively. Good luck!
You're right, it must be my lucky day, I found it, here is (with some arrange):
*****
Dimension aryFiles(1)
=GetAllFiles(GETDIR(), @aryFiles)
SET STEP ON
FUNCTION GetAllFiles(cDirectory, aryParam)
LOCAL ARRAY aryTemp(1,5)
LOCAL nCount, nMax, nLen, cFile
SET DEFAULT TO (cDirectory)
=ADIR(aryTemp, "*.*", "AHRSD", 1)
nMax = ALEN(aryTemp,1)
FOR nCount = 1 TO nMax
cFile = ALLTRIM(aryTemp(nCount,1))
IF !(cFile == ".") AND !(cFile == "..")
IF "D" $ aryTemp(nCount,5)
=GetAllFiles(ADDBS(cDirectory + cFile), @aryParam)
ELSE
nLen = ALEN(aryParam)
IF !EMPTY(aryParam(nLen))
DIMENSION aryParam(nLen + 1)
nLen = nLen + 1
ENDIF
aryParam(nLen) = cDirectory + cFile
ENDIF
? cDirectory + cFile
ENDIF
ENDFOR
ENDFUNC
Source:
http://www.tek-tips.com/faqs.cfm?fid=4256
Thanks for writing that code back in 06! You've greatly simplified my life in '13!
Post a Comment