Page 1 of 1 1
Topic Options
#142132 - 2005-06-22 01:19 AM search for a file and write its path to a variable when found
msigi123 Offline
Fresh Scripter

Registered: 2005-06-22
Posts: 8
hi there

i am looking desperately for a command that searches for a file on a specific drive i.e. C:

All i have is default\doc.dot but that can be anywhere under C:

so what i need to do is to find the whole path of default\doc.dot under that C: drive which maybe looks like that at the end: C:\test\123\default\doc.dot

C:\test\123\default\ should be a variable at the end which i can use to copy new files into it

complicated?

Top
#142133 - 2005-06-22 01:31 AM Re: search for a file and write its path to a variable when found
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no...
not that complicated, specially when you have several UDFs that provide the functionality...
see http://udf.isorg.com

all you need to do is to learn how to use UDFs
_________________________
!

download KiXnet

Top
#142134 - 2005-06-22 01:37 AM Re: search for a file and write its path to a variable when found
msigi123 Offline
Fresh Scripter

Registered: 2005-06-22
Posts: 8
thx

thats what i tried the last 30 minutes...

UDF GetFilePath

but i am not getting the result i wish...

maybe its just too late ... 1:30am

in a batch file i would use the command "for" for that function... is there a similar function for kix`?


Edited by msigi123 (2005-06-22 01:50 AM)

Top
#142135 - 2005-06-22 02:05 AM Re: search for a file and write its path to a variable when found
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
sure, you should get your hands on the manual.

anyways, what you really want from the udf list is obviously dirplus(), dirscan() or one of the similar udfs.
they all can return the full path to the files.
_________________________
!

download KiXnet

Top
#142136 - 2005-06-22 05:26 AM Re: search for a file and write its path to a variable when found
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
If it can be anywhere on the computer, how is this file then usable? The related application will somehow need to know where to look for the file, and so can you.
_________________________
There are two types of vessels, submarines and targets.

Top
#142137 - 2005-06-22 09:06 AM Re: search for a file and write its path to a variable when found
msigi123 Offline
Fresh Scripter

Registered: 2005-06-22
Posts: 8
in my case i need to do updates on a application that you just copy into any folder under i.e. C: the application itself only need its own root path and the files in the subfolders to run...

at the same time thats the tricky part.. so i need to find first the path of this program and after that i can copy and overwrite the old files..

luckily the rootfolder, filenames and the subfolder structure is always the same... so i actually need to look for "root\appl.exe" anywhere on the C: if found the script should give me the path back

anyone able to give me a hint for this?

Top
#142138 - 2005-06-22 11:54 AM Re: search for a file and write its path to a variable when found
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
look above.
try dir!

bloody *%#¤!
to find something, you need to scan the bloody structure and then you can see where it is.
use of brains is allowed.
_________________________
!

download KiXnet

Top
#142139 - 2005-06-22 12:10 PM Re: search for a file and write its path to a variable when found
msigi123 Offline
Fresh Scripter

Registered: 2005-06-22
Posts: 8
guess you have a master degree in social behavior...

thanks for your friendliness

Top
#142140 - 2005-06-22 12:24 PM Re: search for a file and write its path to a variable when found
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
heh, I don't have.
and extreme sillyness gets me always bit angry.
does not matter if it's me or someone else...
_________________________
!

download KiXnet

Top
#142141 - 2005-06-22 01:34 PM Re: search for a file and write its path to a variable when found
msigi123 Offline
Fresh Scripter

Registered: 2005-06-22
Posts: 8
i admitt i am not having sufficient knowhow with kix yet... i am a starter and thats the reason why i post this message here ("When you are new to KiXtart, you can post your questions here")

to find somebody experienced who can help me...

just remember your time as a starter... if it makes you angry please ignore the "starters" forum and look for something more sophisticated for you...

Top
#142142 - 2005-06-22 01:42 PM Re: search for a file and write its path to a variable when found
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
stop whining!
it has nothing to do with kixtart but computer basic skills.
go on, open up your command prompt and try to find a file there.
I say, you would be quite lost without DIR.
_________________________
!

download KiXnet

Top
#142143 - 2005-06-22 02:02 PM Re: search for a file and write its path to a variable when found
msigi123 Offline
Fresh Scripter

Registered: 2005-06-22
Posts: 8
well batch is easy

C:
cd\
dir file.exe /s

and i will get a list of all file.exe under C:

Top
#142144 - 2005-06-22 02:49 PM Re: search for a file and write its path to a variable when found
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
good.
with those dir udfs I told you to look at many posts ago (before you started re-querying for pointers) you get not just the file.exe but full path to each one of them.
_________________________
!

download KiXnet

Top
#142145 - 2005-06-22 03:01 PM Re: search for a file and write its path to a variable when found
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Cool it guys!

Crawling through local drives is not exactly efficient whether by BATch or KiX. What Jens simmply pointed out is that if the app can find the file, one should use the same approach. I am sure the app does not crawl through the entire disk to find it. Normally applications have either reg entries or INI files or rely on the current dir. Any of these can be queried without crawling through the entire drive. You need to start thinking like the app does.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#142146 - 2005-06-22 03:14 PM Re: search for a file and write its path to a variable when found
msigi123 Offline
Fresh Scripter

Registered: 2005-06-22
Posts: 8
well actually the whole application is a VBA piece in winword. so there are no ini, reg-keys or anything else... unfortunately...

i know i wrote app.exe in the earlier posts.. that was my fault... there are only docs dots xls and mdb...

completely independent on where they are located

and every user copied it somwhere on the harddrive as it was introduced... now as we have updates we first need to locate where it is to replace the files

Top
#142147 - 2005-06-22 05:41 PM Re: search for a file and write its path to a variable when found
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well why not take the time now and force a "standard" which will pay off in the long run as you can probably tell now in just this simple example why not following standards in a business can wreak havoc and cost time and money to support the lack of using standards.

That said, were you able to get one of the said UDF scripts to complete the task for you?
 

Top
#142148 - 2005-06-22 07:08 PM Re: search for a file and write its path to a variable when found
msigi123 Offline
Fresh Scripter

Registered: 2005-06-22
Posts: 8
i agree with you about standards.. ;-)

nope.. i went back to batch scripts..
and it is working...
thanks anyways

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
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.123 seconds in which 0.078 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