is there a way to write the file names in a folder in a text file?

This is a discussion on is there a way to write the file names in a folder in a text file? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; i could've done that the slow way, but writing names down for 2000+ files manually is just wrong thankx PS: ...

  1. #1
    Registered User Commander's Avatar
    Join Date
    Sep 2001
    Posts
    804

    is there a way to write the file names in a folder in a text file?

    i could've done that the slow way, but writing names down for 2000+ files manually is just wrong
    thankx

    PS: i tried to do a search for it, but i didn't know that to search for
    Last edited by Commander; 08-15-2002 at 03:02 PM.
    oh i'm sorry! i didn;t realize my fist was rushing to meet ur face!

    MSN :: commander_android@hotmail.com []*[]

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    If you have windows, then you could try this piece of unadulterated evil

    Save as ListFiles.wsf and put in the dir you want to list files for....

    Run it and it should create FileListing.txt..

    I have used with folder of 2000+ files and it seems to cope...even thoug it is slower than using C++ :0
    Code:
    <PACKAGE>
    <JOB>
    <SCRIPT LANGUAGE="JScript">
    //
    // RobJFord 22/6/02
    // List Files in Currect Folder
    //
    // Get File system 
    
    try{
    var oFS = new ActiveXObject("Scripting.FileSystemObject");
    }
    catch(e){
    WScript.Echo("Could not create file system interface");
    WScript.Quit(1);
    }
    
    // Get Dir & Files
    
    try{
    var oThisScript = oFS.GetFile(WScript.ScriptFullName);
    var oCurrDir = oThisScript.ParentFolder;
    oThisScript = "";
    var oFileCol = new Enumerator(oCurrDir.files); 
    }
    catch(e){
    WScript.Echo("Could not enumerate files");
    WScript.Quit(1);
    }
    
    // Create output file and list
    
    try{
    var oOutputFile = oFS.OpenTextFile
    	(oCurrDir + "\\FileListing.txt",2,"TRUE");
    oOutputFile.WriteLine("Listing of " + oCurrDir);
    oOutputFile.WriteLine(oCurrDir.files.Count + " Files");
    
    for (;!oFileCol.atEnd();oFileCol.moveNext()){
          oOutputFile.WriteLine(oFileCol.item());
    }
    
    WScript.Echo("List Made");
    oOutputFile.Close();
    }
    catch(e){
    WScript.Echo("Could not list files");
    WScript.Quit(1);
    }
    oOutputFile = "";
    oFS = "";
    oFileCol = "";
    </SCRIPT>
    </JOB>
    </PACKAGE>

  3. #3
    Registered User Commander's Avatar
    Join Date
    Sep 2001
    Posts
    804
    thankx guys, that really helped out. i really appreciate it.
    oh i'm sorry! i didn;t realize my fist was rushing to meet ur face!

    MSN :: commander_android@hotmail.com []*[]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 01:13 AM
  2. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  3. Removing text between /* */ in a file
    By 0rion in forum C Programming
    Replies: 2
    Last Post: 04-05-2004, 09:54 AM
  4. Write some text to a file
    By Unlimited4s in forum C++ Programming
    Replies: 7
    Last Post: 07-17-2002, 04:37 AM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21