• FileSystemObject woes

    • This topic has 2 replies, 2 voices, and was last updated 24 years ago.
    Author
    Topic
    #355764

    Trying to get a simple loop to nuke files with a certain extension. The following code errors out with file not found on the “Set f” line even though the file is definitely there.

    Set fs = CreateObject(“Scripting.FileSystemObject”)

    With Application.FileSearch
    .FileName = “*.gid”
    .LookIn = strDevelPath
    .SearchSubFolders = True
    .Execute
    For i = 1 To .FoundFiles.Count
    Set f = fs.GetFile(fs.GetFileName(.FoundFiles(i)))
    If f.Attributes And 2 Then f.Attributes = f.Attributes – 2
    If f.Attributes And 1 Then f.Attributes = f.Attributes – 1
    Kill .FoundFiles(i)
    Next
    End With

    Thanks for any input,

    Chris

    Viewing 0 reply threads
    Author
    Replies
    • #525382

      Is there a name property for that object…?

      Set f = fs.GetFile(fs.GetFileName(.FoundFiles(i).Name))

      • #525388

        Got it to work with:

        Set f = fs.GetFile(.FoundFiles(i).Name)

        Thanks,

        Chris

    Viewing 0 reply threads
    Reply To: FileSystemObject woes

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: