Rename file/ReplaceSubString

I have searched the forum and many books and websites but I am still am not able to find how to rename the file. After I am done with the file I want to rename it .old so that the agent does not run on it again.

sendfile is what I want to rename and I know once I get the values I can use

Name sendfile As newname

sendfiles value is “\servername\dir\file.txt”

but I am not sure how do it and have not found any postings that can help me. I am still new to LS so I know I am in the right area but there are a few different ways to do this and I am not show how to word the syntax or where to place it at this point.

Any help would be appreciated.

Here is my code:

Function ProcessFile (sendfile As String, session As Notessession, db As Notesdatabase) As Integer

’ ready a notes memo, the body field is a richtext type.

Dim dbdoc As Notesdocument

Dim body As Notesrichtextitem 

Dim FileAtt As String



Set dbdoc = New NotesDocument( db )

dbdoc.Form = "Memo"

’ open ascii file and read every line

fileNum% = Freefile()

Open sendfile For Input As fileNum%

’ Read each line of the file.

Line Input #fileNum%, txt1	

Line Input #fileNum%, txt2

Line Input #fileNum%, txt3

Close fileNum%

’ Gets the File Name

StartPos = Instr ( txt3 , "\") +1

EndPos =Instr (txt3 , ".")

FileAtt = Mid$(txt3 , StartPos  , EndPos - StartPos)

’ Mail Info

dbdoc.SendTo = txt1

dbdoc.CopyTo = ""

dbdoc.BlindCopyTo = ""

dbdoc.Subject = "Delivery Failure"

Set body = New NotesRichTextItem( dbdoc, "Body" )

Call body.AppendText(clause & Chr$(10))

Set body = New NotesRichTextItem( dbdoc, "Body") 

Call Body.EmbedObject(EMBED_ATTACHMENT, "", ASCIIDir+"\"+FileAtt+".txt")

dbdoc.PostedDate = Now

dbdoc.SaveMessageOnSend = True

Call dbdoc.Send( False)

'Close File

Close fileNum%	

End Function

Subject: Rename file/ReplaceSubString

I would not worry about renaming it, but make a copy of the file. OF course the new copy would have the new name. Then you can delete the old or original file.

…Code based on 6.5…

FileCopy source, destination


Source would be full path and filename

Destination would behte full path and newfilename.

The format is specific to your operating system; i.e. M$ Windows “c:\directory\filename.txt”,

Unix\Linux “/directory/filname.txt”

etc…

HTH – Cheers

Subject: RE: Rename file/ReplaceSubString

That is one of the options I looked at but I want the .old file to have the same file name as the original. This way, if need be, we can go back and look up the file by name and see if it was sent to the customer and to see if my agent ran on it.

That is the part I can’t figure out, how to rename it .old, and keep the same file name.

Subject: RE: Rename file/ReplaceSubString

Then just copy the original file to the .old file and delete the source.

You are going to have to use an OS command to get the renaming done. Which is hard since there is really no Platform on this posting.

I think the FileCopy is as close to the rename function. Copy the file is as good as renaming it.

HTH – Cheers

Subject: RE: Rename file/ReplaceSubString

What you’re looking for is the strLeft function in LS.

dim strPathAndFile as String

strPathAndFile = strLeft(FileName, “.”)

FileCopy(FileName, strPathAndFile & “old”)

Kill FileName

Something like that (you may have to include the “.” in the FileCopy line like so:

FileCopy(FileName, strPathAndFile & “.old”)

I don’t remember if strLeft will return it or not.

There is also a Name statement that does a re-name, but you’ll run into problems if the new filename already exists.

hth

Dana

Subject: RE: Rename file/ReplaceSubString

Thanks for help and responding.

I ended up using the Name function and renaming the file to a different dir. I know that the name will always be unique becuase the files are time/date stamped with a unique acknowledgement number.

Next time I need to rename though I will try your suggestion.

Thanks again, Dana