Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename file as (TODAY) 2

Status
Not open for further replies.

Majaws2

Programmer
Jul 3, 2003
15
0
0
US
I was trying to rename a file using aspect, so that the script does not overwrite or append to the existing file. Any ideas, I am currently using the below, but need to name file as a date string.

proc newname
string Fname = "C:\Program Files\symantec\Procomm Plus\Capture\testdump.cap"
string NewFName = "C:\Program Files\symantec\Procomm Plus\Capture\today.cap"

if not rename Fname NewFName
errormsg "Couldn't rename `"%s`" to `"%s`"." Fname NewFName
endif
endproc
 
Spoke to soon

Ok the script works, but I need one more thing. I know how to write it in C++ and Basic, but not Aspect.


There may be time where there are multiple file in the directory that are name arp370_8,arp370_9,arp370_10.
Presently I have to run the script 3 times to get it to upload all 3 files. Is there a way to set up a sub routine to get it to seach and uplaod every arp370_* until it is done, then end the script.
 
You can use the while findnext command to search for additional filed matching arp370*.*, then run the same commands inside that while loop. Here is a modified version of the script that does it:

proc main
string FileSpec = "s:\arp370*.*" ; File specifications to look for.
string FileName
string FilePath = "c:\arp370\archive\"
integer iDay, iMonth, iYear, iHour, iMin, iSec

dial data "cc"
while $dialing
yield
endwhile
if ! $carrier
statmsg "Connection attempt failed."
exit
endif

statmsg "Sending file to Paymentech"

set ascii timeout 40
pause 5
if findfirst FileSpec ; Find first file matching spec.
sendfile ascii FileSpec
while $xferstatus
yield
endwhile

getfile ascii "T:\download.txt"
while $xferstatus
yield
endwhile

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt FileName "%s%s%02d%02d%d.%s" FilePath $FNAME iMonth iDay iYear $FEXT
copyfile $FILESPEC FileName
if success
delfile $FILESPEC
endif

;while $carrier
; yield
; endwhile

waitfor "EOFEOFEOF"
;if success
pause 5
hangup
;endif
while findnext
sendfile ascii FileSpec
while $xferstatus
yield
endwhile

getfile ascii "T:\download.txt"
while $xferstatus
yield
endwhile

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt FileName "%s%s%02d%02d%d.%s" FilePath $FNAME iMonth iDay iYear $FEXT
copyfile $FILESPEC FileName
if success
delfile $FILESPEC
endif

;while $carrier
; yield
; endwhile

waitfor "EOFEOFEOF"
;if success
pause 5
hangup
;endif
endwhile
else
errormsg "No files found!"
endif
endproc

aspect@aspectscripting.com
 
Last one does not work. For some reason, the connection to the modem hangsup after the 1st upload, then the program continues to look for the 2nd and 3rd file while the lost modem has disconnected it's connection. Is it possible that the loop is in the wrong place?
 
Ah, didn't see that the hangup command was in the script. To workaround that, remove the two instances of the hangup command, then put it after the endwhile command toward the end of the script. Actually, here's a modified version:

proc main
string FileSpec = "s:\arp370*.*" ; File specifications to look for.
string FileName
string FilePath = "c:\arp370\archive\"
integer iDay, iMonth, iYear, iHour, iMin, iSec

dial data "cc"
while $dialing
yield
endwhile
if ! $carrier
statmsg "Connection attempt failed."
exit
endif

statmsg "Sending file to Paymentech"

set ascii timeout 40
pause 5
if findfirst FileSpec ; Find first file matching spec.
sendfile ascii FileSpec
while $xferstatus
yield
endwhile

getfile ascii "T:\download.txt"
while $xferstatus
yield
endwhile

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt FileName "%s%s%02d%02d%d.%s" FilePath $FNAME iMonth iDay iYear $FEXT
copyfile $FILESPEC FileName
if success
delfile $FILESPEC
endif

;while $carrier
; yield
; endwhile

waitfor "EOFEOFEOF"
;if success
pause 5
;endif
while findnext
sendfile ascii FileSpec
while $xferstatus
yield
endwhile

getfile ascii "T:\download.txt"
while $xferstatus
yield
endwhile

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt FileName "%s%s%02d%02d%d.%s" FilePath $FNAME iMonth iDay iYear $FEXT
copyfile $FILESPEC FileName
if success
delfile $FILESPEC
endif

;while $carrier
; yield
; endwhile

waitfor "EOFEOFEOF"
;if success
pause 5
;endif
endwhile
hangup
else
errormsg "No files found!"
endif
endproc

aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top