Thread: Stripping Files out of Dirs

  1. #1
    Registered User
    Join Date
    Jun 2003

    Stripping Files out of Dirs

    I am looking to create a program/script that will go through 1 directory and look for the file extension .jpg . Now, this directory will have subdirectories and I need the program to be able to read and parse through those as well.
    I tried something in VBscript, but would like to do the same in C++

    Option Explicit
    on error resume next
    Dim FileSystemObj
    Dim FolderPath
    Dim folder
    Dim FileList
    Dim File
    Dim DaysOld
    'set how far back to delete
    DaysOld = 30
    Set FileSystemObj = CreateObject("Scripting.FileSystemObject")
    'set the directory
    FolderPath = "C:\ImageDir"
    set folder = FileSystemObj.GetFolder(FolderPath)
    set FileList = folder.Files
    'test each file's age and delte if older than DaysOld
    For each File in FileList
    If File.DateLastModified < (Date() - DaysOld) Then
    End If
    'Tidy up
    Set FileSystemObj = Nothing
    Set folder = Nothing
    Set FileList = Nothing
    Set File = Nothing
    This code also deletes the files if they are 30 days old. I need it to be able to do that. However, this script does not go through subdirectories. I kind of pieced this code together from other VB sites and help from others.

    Any help would be greatly appreciated.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    There are several examples of how to walk the directory tree in the FAQ.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading .dat files from a folder in current directory...
    By porsche911nfs in forum C++ Programming
    Replies: 7
    Last Post: 04-04-2009, 09:52 PM
  2. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  3. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  4. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  5. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM