#24819 - 2002-07-11 02:45 PM
How to find a file????
|
atiisler
Fresh Scripter
Registered: 2002-07-10
Posts: 34
|
Hi, I am new to Kixtart and have a problem I can't solve.
I need to first read thru a folder and locate a particular file. The problem is I don't know the file name only the extension. There is only one file with this extension. I know how to read the files in folder, but I do not know how to capture the filename of the file when read. Then once I read the file I am looking for I need to assign this text to a variable.
|
|
Top
|
|
|
|
#24821 - 2002-07-11 03:19 PM
Re: How to find a file????
|
atiisler
Fresh Scripter
Registered: 2002-07-10
Posts: 34
|
Thank you soo much...I was actually using something similar but all I was doing was looping
Code: ;$id = dir("c:\lotus\notes\data\*.*") ;while $id <> "" and @error = 0
; ? $id ; ;if $id = "*.id" ; ; ? "Eureka, I did it" ; ;endif
; $id = dir() ;retrieve next file ;loop
I didn't realize I code specify the extension in the DIR line...
Thank you again for such a quick response.... Also....can I use the command Xcopy with kixtart? I know copy is available but does not have the switches of Xcopy like /i ( which will create a folder if not already there)
Thanks again
|
|
Top
|
|
|
|
#24823 - 2002-07-11 05:03 PM
Re: How to find a file????
|
atiisler
Fresh Scripter
Registered: 2002-07-10
Posts: 34
|
I don't mean to sound so dumb....but I really do not understand that line of code..I tried to use it and got zip.... if i put that line of code in can i then use the XCOPY command in kixtart...if not where would I put the file copy information? Thanks for all your help
|
|
Top
|
|
|
|
#24825 - 2002-07-11 05:28 PM
Re: How to find a file????
|
atiisler
Fresh Scripter
Registered: 2002-07-10
Posts: 34
|
Would this be accurate way to code if I wanted to copy file names.nsf to folder test, both on C: drive of local machine?
shell "%comspec% /c xcopy /i c:\names.nsf C:test" if @error = 0 ? "found" else ? "not found" endif
|
|
Top
|
|
|
|
#24827 - 2002-07-11 05:40 PM
Re: How to find a file????
|
atiisler
Fresh Scripter
Registered: 2002-07-10
Posts: 34
|
That was just an example. What I really want to do is copy a file ( the one I found using the DIR command you sent me that I only knew ext for) from the users local drive to a network drive and if the folder does not exist to create it on the fly and copy the file to it. ( the XCOPY switch /i will create a folder, file, etc that does not exist)
Since this is my main goal can it be done? I really appreciate all your help.
|
|
Top
|
|
|
|
#24830 - 2002-07-11 06:25 PM
Re: How to find a file????
|
atiisler
Fresh Scripter
Registered: 2002-07-10
Posts: 34
|
That code makes total sense...and most of it works. But for some reason this line is not finding my file...
$sourcefile='c:\Lotus\Notes\Data\names.nsf'
the directory is being created but no file is copied. I checked to make sure file exists and it does...any ideas
Thank you thank you again
|
|
Top
|
|
|
|
#24832 - 2002-07-11 07:06 PM
Re: How to find a file????
|
atiisler
Fresh Scripter
Registered: 2002-07-10
Posts: 34
|
Sorry, it did work. I just had a wrong puctuation.
Why does it seem like the things that should be easy just don't seem to be. I am trying to create a variable that contains the value of a previous variable. Shouldn't it just be
$x = $y
with $y now being whatever $x was..???
|
|
Top
|
|
|
|
#24833 - 2002-07-11 07:10 PM
Re: How to find a file????
|
atiisler
Fresh Scripter
Registered: 2002-07-10
Posts: 34
|
it does....my typing is a bit to be desired..so an extra space here or there sure makes a diffrence in the outcome....
You guys are really a great help....
|
|
Top
|
|
|
|
#24835 - 2002-07-11 08:00 PM
Re: How to find a file????
|
atiisler
Fresh Scripter
Registered: 2002-07-10
Posts: 34
|
why won't this work:
code $id = file name found previously
$sourcefile="c:\Lotus\Notes\Data\names.nsf"
$targetdir="\\orrm\domino\local_notes\" + "$id"
if not exist($targetdir) md $targetdir
copy $sourcefile $targetdir
When I run this the folder is created in the right target directory with the right name but then when I get to the copy statement I get and error that says "system can not find path specified" showing the correct paths for copying from and to...
Once I get this part I will be almost done.....
|
|
Top
|
|
|
|
#24838 - 2002-07-11 09:11 PM
Re: How to find a file????
|
atiisler
Fresh Scripter
Registered: 2002-07-10
Posts: 34
|
I am a Dudette ;}
What I am trying to do is create a script that copies the file names.nsf into a folder that is created using the *.id file. This file is going to be diffrent for each user, the only similarity is the .id extension. Once I capture this file using
code: $id = dir("c:\lotus\notes\data\*.id") if @error = 0 ? "no error" else @error = 1 ? "there is an error"+ @serror+"You should notify the Administrator" endif
What I want to do then is to create a folder on the network and name it using the .id file for identification of the user. That is why i needed to create the value of $id variable. After the folder is created I need to then copy the name.nsf for a particular user and copy it to the folder that was created with .id file. It doesn't really matter that the folder is named the same( just identification purposes) as the file I located since the file I want to copy is a diffrent file altogether. So what I need to do is pull the names.nsf file from the local user and copy it into the folder I created on the netork.
If I use the the code you last sent it copies the .id file not the names.nsf which is the source file($sourcefile) I can accomplish this if I hard code the $targetdir as such.
Code: $targetdir="\\orrm\domino\local_notes\atiisler.id"
Everything works fine then. The atiisler.id folder is created and the names.nsf file is copied into it. The problem is that every user has a diffrent .id file and I would have to hardcode it for over 100 users. So I want to set it up based on the .id file that is found. And if that user doesn't have a folder to create it. Does this help? What I am trying to do is to create a backup of a file for Lotus notes. The .nsf is = .pst, but notes does load to server only on local station which is not backed up daily the server is. We need to do this for purposes of restoration. Sorry so lenghy guys.......Thanks AGAIN
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 973 anonymous users online.
|
|
|