#154928 - 2006-01-09 11:41 PM
Help with Dir()
|
daniel1982
Getting the hang of it
Registered: 2005-03-23
Posts: 77
Loc: Sydney, Australia
|
Hi All,
any ideas why this is not working? @error returns 0 for both Dir() calls, but it gets in an infinite loops at ?"hello5:" and the filename is simply "."?
Code:
break on Dim $Directory $Directory = "\\server\share" Dim $f $f = CreateObject("Scripting.FileSystemObject")
?"hello1" If Exist ($Directory) $Folder = Dir($Directory) ?"Hello2: " + $Folder + " error: " + @error
While $Folder <> "" and @ERROR = 0 ;and $f.IsFolder($Directory + $Folder) ?"hello3" If $Folder <> "." or $Folder <> ".." $FileName = Dir($Directory + $Folder, 1) ; retrieve next file ?"hello4 error: " + @error While $FileName <> "" or $Filename <> "." or $FileName <> ".." and @error = 0 If $Filename <> "." or $Filename <> ".." ? "Directory: " + $Directory + $Folder ?"hello5:" + $FileName If Right($FileName, 4) = ".htm" ?$Filename + " is htm file" EndIf EndIf $FileName = Dir($Directory + $Folder, 1) ? " Getting new filename: " + $Filename Loop EndIf $Folder = Dir($Directory) Loop endIf
|
|
Top
|
|
|
|
#154929 - 2006-01-10 12:05 AM
Re: Help with Dir()
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
you are missing the whole $index thingy from the instructions
|
|
Top
|
|
|
|
#154930 - 2006-01-10 12:09 AM
Re: Help with Dir()
|
daniel1982
Getting the hang of it
Registered: 2005-03-23
Posts: 77
Loc: Sydney, Australia
|
Code:
$FileName = Dir($Directory + $Folder, 1)
Isn't that the one?
|
|
Top
|
|
|
|
#154932 - 2006-01-10 12:26 AM
Re: Help with Dir()
|
daniel1982
Getting the hang of it
Registered: 2005-03-23
Posts: 77
Loc: Sydney, Australia
|
So it should be $FileName = Dir("", 1) and $Folder = Dir()? This still seems to be giving me the same problem...?
|
|
Top
|
|
|
|
#154934 - 2006-01-10 04:15 AM
Re: Help with Dir()
|
daniel1982
Getting the hang of it
Registered: 2005-03-23
Posts: 77
Loc: Sydney, Australia
|
This is what I'm trying to do:
$Directory is a directory full of Folders. within each of these folders is a number of .htm files. I basically need to copy each of these .htm files, parse them a bit and create a new .shtm file in the same directory. What i've attempted to do so far is just get the filenames to parse.
ie:
Code:
Dir(The directory containing the folders) While There are no errors Dir(the folder underneath the original directory) While there are no erros ?Show the filename Dir(the folder underneath the original directory) Loop Dir(the directory containing the folders) Loop
Does that make more sense?
|
|
Top
|
|
|
|
#154937 - 2006-01-10 04:54 AM
Re: Help with Dir()
|
daniel1982
Getting the hang of it
Registered: 2005-03-23
Posts: 77
Loc: Sydney, Australia
|
OK, so i've taken out the debug statements, and added back in the fso query, can anyone tell me why this isn't working?
Code:
break on Dim $Directory $Directory = "\\nucnas02\intratst_content\busservices\procurement_home\pres\ProductGuide\" Dim $f $f = CreateObject("Scripting.FileSystemObject")
If Exist ($Directory) $Folder = Dir($Directory)
While $Folder <> "" and @ERROR = 0 and $f.IsFolder($Directory + $Folder) If $Folder <> "." or $Folder <> ".." $FileName = Dir($Directory + $Folder, 1) ; retrieve next file While $FileName <> "" or $Filename <> "." or $FileName <> ".." and @error = 0 If $Filename <> "." or $Filename <> ".." If Right($FileName, 4) = ".htm" ?$Filename + " is htm file" EndIf EndIf $FileName = Dir("", 1) Loop EndIf $Folder = Dir() Loop endIf
|
|
Top
|
|
|
|
#154940 - 2006-01-10 06:33 AM
Re: Help with Dir()
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11629
Loc: CA
|
Quote:
***.JOOEL
You know you can be just Jooel on your own system 
But that's a nice long path to type at dos console.
[censored by jooel ]
Edited by Jooel (2006-01-10 07:08 AM)
|
|
Top
|
|
|
|
#154943 - 2006-01-10 10:40 AM
Re: Help with Dir()
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11629
Loc: CA
|
LOL - I thought it was an encryption line
|
|
Top
|
|
|
|
#154944 - 2006-01-10 03:12 PM
Re: Help with Dir()
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
Code:
Dim $Directory, $file
$Directory = "\\nucnas02\intratst_content\busservices\procurement_home\pres\ProductGuide\"
for each $file in dirplus($directory,'/ad /f htm') ? $file.name " " $file.path next
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1183 anonymous users online.
|
|
|