#12312 - 2001-09-17 10:19 PM
using dir to parse files.
|
j95661
Getting the hang of it
Registered: 2001-02-27
Posts: 84
Loc: sacramento,ca usa
|
$filename = Dir("c:\temp") While $filename <> "" And @ERROR = 0 ? $filename Dir() LoopIf I run this in debug mode $filename comes up as "." and I see the actual file after dir() . I cant figure out how to get the file into $filename. I am basically trying to parse a directory that has filenames of computers which do not have extensions. I read the manual on dir and the example is not working for me. any help would be great. [ 17 September 2001: Message edited by: j95661 ]
_________________________
WonderBoy
Constantly learning everyday, how much I dont know :-)
|
|
Top
|
|
|
|
#12313 - 2001-09-17 10:39 PM
Re: using dir to parse files.
|
Les
KiX Master
   
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
Did you try it exactly as the example shows? In my 3.62 html help file, it has the following example (I aded the Break and Get):
code:
break on $FileName = Dir("C:\TEMP") While $FileName <> “” and @ERROR = 0 ? $FileName Dir() ; retrieve next file Loopget $
This returned" TempIf I modify as follows:
code:
break on $FileName = Dir("C:\TEMP\*.*") While $FileName <> “” and @ERROR = 0 ? $FileName Dir() ; retrieve next file Loopget $
I get the following results: ... .FFINQU32.ENU .New Text Document (2).txt .New Text Document.txt . What do you get?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
|
|
Top
|
|
|
|
#12314 - 2001-09-17 10:46 PM
Re: using dir to parse files.
|
j95661
Getting the hang of it
Registered: 2001-02-27
Posts: 84
Loc: sacramento,ca usa
|
I am getting the same results as well. But notice what is happening.... .temp.txt . the period is being written as the value of $filename then the file temp.txt is coming after Dir() that is whats boggling me. I want to get rid of "." and I just want the file name to be in the variable $filename.
_________________________
WonderBoy
Constantly learning everyday, how much I dont know :-)
|
|
Top
|
|
|
|
#12315 - 2001-09-17 11:10 PM
Re: using dir to parse files.
|
j95661
Getting the hang of it
Registered: 2001-02-27
Posts: 84
Loc: sacramento,ca usa
|
This is whats happening.$filename = Dir("c:\temp") while $filename <> "" and @ERROR = 0 ? $filename Dir() loop $filename seems to be being set to the root of the directory, which is ".". Dir() is calling the next value in $filename but it is never being used. this is what I tried and it works. $filename = Dir("c:\temp") while $filename <> "" and @ERROR = 0 $host = Dir() ? $host Dir() loop this outputs what I want. $filename seems to be acting as an array, but in the example it is never being incremented to the next value, except after dir(). thanks
_________________________
WonderBoy
Constantly learning everyday, how much I dont know :-)
|
|
Top
|
|
|
|
#12317 - 2001-09-17 11:17 PM
Re: using dir to parse files.
|
j95661
Getting the hang of it
Registered: 2001-02-27
Posts: 84
Loc: sacramento,ca usa
|
oops I spoke too soon. My solution from last post actually increments the value of $filename twice.well back to the drawing board. I just might have to call a For loop if this will not work.
_________________________
WonderBoy
Constantly learning everyday, how much I dont know :-)
|
|
Top
|
|
|
|
#12318 - 2001-09-18 12:31 AM
Re: using dir to parse files.
|
j95661
Getting the hang of it
Registered: 2001-02-27
Posts: 84
Loc: sacramento,ca usa
|
I finally see the main part of my problem. Parsing the "." works and getting the filename works, but kixtart doesnt seem to like sending that value to shell.ex. Shell "%compspec% /c ping $filename" that seems to be my problem all along. When I run debug and look at what is being sent to shell, I get the whole directory listing. This must not be a variable that is able to be sent to a shell command. If anyone knows of a way of doing this Id stop ranting about this. :-) Thanks again
_________________________
WonderBoy
Constantly learning everyday, how much I dont know :-)
|
|
Top
|
|
|
|
#12321 - 2001-09-18 01:50 AM
Re: using dir to parse files.
|
j95661
Getting the hang of it
Registered: 2001-02-27
Posts: 84
Loc: sacramento,ca usa
|
Shawn is RC3 going to allow me to send the results to a shell.break on$ $filename = Dir("c:\temp") While $filename <> "" and @error =0 Shell "%comspec% /c ping $filename" $filename = DIR() loop if I use that context with 3.61 it doesnt work. That is the current problem sending the result of $filename to shell.
_________________________
WonderBoy
Constantly learning everyday, how much I dont know :-)
|
|
Top
|
|
|
|
#12323 - 2001-09-18 02:49 AM
Re: using dir to parse files.
|
j95661
Getting the hang of it
Registered: 2001-02-27
Posts: 84
Loc: sacramento,ca usa
|
Thanks a bunch you guys.. I was running an older version of kixstart than I thought. Downloaded RC3 and its working great.Thanks again for you help.
_________________________
WonderBoy
Constantly learning everyday, how much I dont know :-)
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 847 anonymous users online.
|
|
|