Page 1 of 1 1
Topic Options
#138039 - 2005-04-15 12:25 PM $file variable question
AndyK Offline
Fresh Scripter

Registered: 2005-03-29
Posts: 8
Hi,
I am using the WriteProfileString command. I want to output file name, file location and modified date to a txt file.

I have managed to get the name and modified date done using $file.name and $file.datelastmodified. But I cannot find how to output the location. I have tried $file.location and $file.path, that just throws the whole thing out and leaves the output txt file blank. Does anyone know what $file variable I should be using.

Thanks,

Andy

Top
#138040 - 2005-04-15 01:51 PM Re: $file variable question
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
First off, I assume $file is a COM reference and not any intrinsic KiX function, therefore you should state that. A little snippet of code wouldn't hurt too.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#138041 - 2005-04-15 01:52 PM Re: $file variable question
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
THat said, here are a few FSO props.
Code:

Function GetAllFileProperties($FileName)
$fso = CreateObject("Scripting.FileSystemObject")
$objFile = $fso.GetFile($FileName)
? "Date created: " + $objFile.DateCreated
? "Date last accessed: " + $objFile.DateLastAccessed
? "Date last modified: " + $objFile.DateLastModified
? "Drive: " + $objFile.Drive
? "Name: " + $objFile.Name
? "Parent folder: " + $objFile.ParentFolder
? "Path: " + $objFile.Path
? "Short name: " + $objFile.ShortName
? "Short path: " + $objFile.ShortPath
? "Size: " + $objFile.Size
? "Type: " + $objFile.Type
EndFunction

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#138042 - 2005-04-15 02:04 PM Re: $file variable question
AndyK Offline
Fresh Scripter

Registered: 2005-03-29
Posts: 8
Hi Les,
I am using it in after calling the dirplus udf.
Complete script below:

Call 'C:\Documents and Settings\username\Desktop\dirplus.kix'
$files = Dirplus("c:\","/a-d /s /f exe")
For Each $file In $files
$ = WriteProfileString('\\server\share\log.ini',@USERID,$file.name,$file.datelastmodified)

Next

Thanks,

Andy

Top
#138043 - 2005-04-15 02:27 PM Re: $file variable question
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Then I surmised correctly since DirPlus() uses FSO and I already answered your question. In the future, I suggest you provide more accurate details when you post so that we do not have to call on the spirits from beyond.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#138044 - 2005-04-15 03:44 PM Re: $file variable question
AndyK Offline
Fresh Scripter

Registered: 2005-03-29
Posts: 8
Fair enough - being a kix novice and not knowing what FSO and COM are I did not know the exact context of how I was using it was important and that there would be a generic answer.
So - just to clarify - does that whole passage of script need to be copied into my script?

Thanks

Top
#138045 - 2005-04-15 03:49 PM Re: $file variable question
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
No, do not copy that into yor script. I posted it simply to show the different properties that FSO returns rather than have you guess at them as you were trying to.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#138046 - 2005-04-15 04:47 PM Re: $file variable question
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
something liek this?

Code:


$files = Dirplus('.\','/a-d /s /f kix')

For Each $file In $files
$ = WriteProfileString('.\test.ini',@USERID,$file.name,$file.datelastmodified + ',' + $file.path)
Next




will make a ini file like this.

Code:

[bsmith]
test.kix=4/15/2005 9:34:54 AM,G:\kix\sandbox\test.kix
800k.kix=3/4/2005 3:30:46 PM,G:\kix\sandbox\800k.kix
av.kix=1/25/2005 5:07:51 PM,G:\kix\sandbox\av.kix
bryce's NicSpeed.kix=3/16/2005 6:03:33 PM,G:\kix\sandbox\bryce's NicSpeed.kix
fncCheckAV.kix=1/26/2005 5:05:46 PM,G:\kix\sandbox\fncCheckAV.kix
months.kix=2/17/2005 6:58:31 PM,G:\kix\sandbox\months.kix
mx2.kix=12/16/2004 4:26:47 PM,G:\kix\sandbox\mx2.kix
NicSpeed.kix=3/16/2005 6:18:20 PM,G:\kix\sandbox\NicSpeed.kix
outlook.kix=4/12/2005 12:31:37 PM,G:\kix\sandbox\outlook.kix
pc.kix=1/3/2005 11:37:57 AM,G:\kix\sandbox\pc.kix
quota.kix=2/24/2005 11:55:42 AM,G:\kix\sandbox\quota.kix
shutdown.kix=12/21/2004 4:34:55 PM,G:\kix\sandbox\shutdown.kix
skincalc.kix=2/10/2005 1:45:37 PM,G:\kix\sandbox\skincalc.kix
temp.kix=1/6/2005 10:31:58 AM,G:\kix\sandbox\temp.kix
vendetta.kix=12/2/2004 2:43:01 PM,G:\kix\sandbox\vendetta.kix
xchat.kix=12/7/2004 5:30:49 PM,G:\kix\sandbox\xchat.kix


Top
#138047 - 2005-04-15 05:03 PM Re: $file variable question
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
But he said "I have tried $file.location and $file.path" although I did not see it in his code.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#138048 - 2005-04-15 05:23 PM Re: $file variable question
AndyK Offline
Fresh Scripter

Registered: 2005-03-29
Posts: 8
Hi Bryce,
That's it! the variable I was using was correct, but I had it set ou like this:
$ = WriteProfileString('\\server\shares\log.ini,@USERID,$file.name,$file.datelastmodified,$file.path)

Thanks everso much for that, one other question. using dirplus, is there a way of searching using part of the filename?
the command in dos is dir c:\blah*.exe
Looking through the dirplus kix, it shows you can search on extension, but all the ways I have tried to add the part of the filename it, it fails.

Thanks again

Andy

Top
#138049 - 2005-04-15 05:32 PM Re: $file variable question
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
THat would be the mask option

/M Apply mask string to filter based on InSTR(), separate each search string with an |.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#138050 - 2005-04-15 06:09 PM Re: $file variable question
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
something like this

dirplus('c:\','/s /a-d /m blah /f exe')

Top
#138051 - 2005-04-15 06:17 PM Re: $file variable question
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
just wonder... if he wants executable files or just exe-files.
with that dirplus stuff, only the latter is suitable.
_________________________
!

download KiXnet

Top
#138052 - 2005-04-15 10:22 PM Re: $file variable question
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Quote:

just wonder... if he wants executable files or just exe-files.
with that dirplus stuff, only the latter is suitable.




what do you mean by executable vs just exe?

Top
#138053 - 2005-04-15 11:19 PM Re: $file variable question
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
.pif, .com, .etc... ??
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.065 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org