Re: Recurse issue - 2nd try



Jeff,

- how many folders deep does it go?
- can you check it with just a few folders deep (5 could be a good number)?
- if successful try adding more folders deep, and see if you get the same
problem. If you do, it will be because of a stack overflow.

Your problem sound very familiar. Sometime ago I made a VB application to
write down the directory tree and like you, i used recursion to move inside
all folders.
When i ran it from a folder, it would work well but when using the root to
go into all the folders, it would skip some. Later I realize that it was a
stack problem associated with the recursion. Recursion will add the paths
to the stack, if the stack overflows some items will not be recorded. When
the recursion ends and tries to grab the next path from the stack, it will
not know about the spilled ones and continue.

- the second error i got was "419 permission to use object denied" or "70
access denied" and it came from reading the administrator profile tree. I
was using my personal account with administrator rights however the
administrator account was set to have the folders permissions set to only
the administrator account.

hope this helps,
Rafael

"Jeff" <zeppdaddy@xxxxxxxxx> wrote in message
news:o3mrp2uavv68.31piex1bryh9$.dlg@xxxxxxxxxxxxx
> My script simply stops short.
>
> What was confusing me most was that I still receive the prompt asking me
> to
> view the log file. Therefore, I was under the impression that it has
> completed it cycle.
>
> However, when I view the log file, it is missing several files.
>
> As far as permissions are concerned, I am not the owner, however all
> groups/users are given full permissions.
>
> On Tue, 5 Jul 2005 11:38:19 +0900, Rafael T wrote:
>
>> Jeff,
>>
>> is your script hanging or does it complete but somehow misses some
>> folders?
>> There are two issues when checking folders:
>> - Recursion uses lots of memory which can stop certain iterations of your
>> recursive call making it miss some folders
>> - Folder permissions might stop your program even if you are the
>> administrator (unless all your folders are own by your account)
>>
>> try catching the error and post it, so we can see it
>> Rafael
>>
>>
>> "Jeff" <zeppdaddy@xxxxxxxxx> wrote in message
>> news:%23uo3AFMgFHA.3232@xxxxxxxxxxxxxxxxxxxxxxx
>>>I am writing a script to look for duplicate files (regardless of
>>>extention).
>>>
>>> This script appears to be working as desired except that it stops short
>>> while recursing through the subfolders.
>>>
>>> I am a relative newbie, can anyone help point me in the right direction?
>>>
>>> Any help is most appreciated.
>>>
>>> I have included my code for review.
>>>
>>> Thanks a million!!
>>>
>>>
>>> --- Begin Code ---
>>>
>>> ' -- NCDupeFinder.vbs
>>>
>>> ' *********************************
>>> ' Constants
>>> ' *********************************
>>>
>>> Const MCAM_FOLDER_ROOT = "R:\MCNC\"
>>> Const ESPRIT_FOLDER_ROOT = "R:\NC\"
>>> Const LOG_FILE = "C:\DuplicateLog.txt"
>>>
>>> ' -- Start Script
>>>
>>> On Error Resume Next
>>>
>>> Query = MsgBox("This script searches for duplicate NC code and may take
>>> a
>>> moment, do you wish to proceed?", vbYesNo + 32 + 256,
>>> "NCDupeFinder.vbs")
>>>
>>> If Query = 6 Then 'yes
>>>
>>> Dim oFSO
>>> Dim sLogFile
>>>
>>> Set oFSO = CreateObject("Scripting.FileSystemObject")
>>>
>>> If oFSO.FileExists(LOG_FILE) Then
>>> oFSO.DeleteFile(LOG_FILE)
>>> End If
>>>
>>> Set sLogFile = oFSO.OpenTextFile(LOG_FILE, 8, True)
>>>
>>> sLogFile.WriteLine("Log File Written: " & Date & " @ " & Time)
>>> sLogFile.WriteLine("")
>>>
>>> CheckAllFiles oFSO.GetFolder(MCAM_FOLDER_ROOT)
>>>
>>> ' -- View Log File
>>> ViewLog = MsgBox("Log complete, would you like to view the log now?",
>>> vbYesNo + 32 + 256, "Message")
>>>
>>> If ViewLog = 6 Then 'yes
>>> Set WshShell = WScript.CreateObject( "WScript.Shell" )
>>> WshShell.Run ("Notepad.exe " & LOG_FILE) 'open log file
>>> End If
>>>
>>> Else MsgBox "Script cancelled by user."
>>>
>>> End If
>>>
>>> ' *********************************
>>> ' CheckAllFiles Sub-Routine
>>> ' *********************************
>>>
>>> Sub CheckAllFiles(oFolder)
>>> Dim oSubFolder, oFile
>>> Dim sNCfilename, sMCNCfilename
>>> Dim intPos
>>>
>>> For Each oFile In oFolder.Files
>>> sMCNCfilename = oFile.Path
>>> sNCfilename = Replace(sMCNCfilename, MCAM_FOLDER_ROOT,
>>> ESPRIT_FOLDER_ROOT)
>>> intPos = InStrRev(sNCfilename, ".")
>>> sNCfilename = Left(sNCfilename, intPos - 1)
>>>
>>> If oFSO.FileExists(sNCfilename & ".nc") Then
>>> sLogFile.WriteLine(sNCfilename & ".nc")
>>>
>>> ElseIf oFSO.FileExists(sNCfilename & ".cnc") Then
>>> sLogFile.WriteLine(sNCfilename & ".cnc")
>>>
>>> ElseIf oFSO.FileExists(sNCfilename & ".min") Then
>>> sLogFile.WriteLine(sNCfilename & ".min")
>>>
>>> ElseIf oFSO.FileExists(sNCfilename & ".iso") Then
>>> sLogFile.WriteLine(sNCfilename & ".iso")
>>>
>>> End If
>>>
>>> Next
>>>
>>> For Each oSubFolder In oFolder.SubFolders
>>> CheckAllFiles oSubFolder
>>> Next
>>>
>>> End Sub
>>>
>>> --- End Code ---
>>>
>>>


.



Relevant Pages

  • Re: cant get access to disk share when connecting from a remote s
    ... still don't get permission to access anything below the folders. ... At any rate I am always mounting using the administrator user/pass. ... >> Dim intTotalErrors ... >> setting the maximum number of simultaneous connections ...
    (microsoft.public.windows.server.scripting)
  • RE: Recursive function, where am I?
    ... Recursion, see recursion. ... As you can see, Parent is the recursive??? ... Set up a CurrentFolder property. ... The Folders class has "Parent", ...
    (microsoft.public.dotnet.languages.csharp)
  • Renaming folders
    ... Dim objFSo As New FileSystemObject ... Dim objFolder As Folder ... 'loop through all folders in this directory ... > recursion in this context ...
    (microsoft.public.excel.programming)
  • Re: Recurse issue - 2nd try
    ... is your script hanging or does it complete but somehow misses some folders? ... There are two issues when checking folders: ... - Recursion uses lots of memory which can stop certain iterations of your ... > Dim sLogFile ...
    (microsoft.public.scripting.vbscript)
  • Re: Accessing sub-folders from AppleScript
    ... First time I used recursion in years... ... I wrote my script because of the new release of DragThing (which can display ... > folders. ... > 'parent' of a folder, but you need a workaround when you get to top-level ...
    (microsoft.public.mac.office.entourage)