Robert Kuhlemann: ordnerinhalte auslesen

Beitrag lesen

Hallo,
so funzt es bei mir:

<script>

FSO = new ActiveXObject("Scripting.FileSystemObject") // MS FileSystemObject
LPA = window.location.href  // make LPA local path
LPA = LPA.substr(0,LPA.lastIndexOf('/') + 1)
LPA = LPA.replace(/file:////,'')
LPA = unescape(LPA)

FOL = FSO.GetFolder(LPA) // oder Klartext zB 'C:/BMC'

document.write(
 FOL + ' enthält<br>'
 + FOL.Files.Count + ' Dateien und<br>'
 + FOL.Subfolders.Count + ' Verzeichnisse<br>')

ct = 0
LOOP = new Enumerator(FOL.Files)
for(;!LOOP.atEnd(); LOOP.moveNext()){
  x = LOOP.item().Name.toLowerCase();
  if(x.substr(x.length-4) != '.txt') continue
  ct++
  document.write(ct + ' ' + x + '<br>')
}

</script>