Rename file after VI import

SOLVED

I need to be able to automatically rename a file after importing it with VI. From other posts I've found a solution that almost works. I can rename the file if I hardcode the import file name using a slightly modified version of Slade's code:

! Slade Hornick
! Rename the source file
! Date: 05/03/2005
!
! Put the Import file in something more manageble
!f$=vi2_import_file$ (Slade's orig)
f$="C:\Projects\Misc 2014\MAS90\VI\imports\test1.csv"
!
! Parse out the directory
f_dir$=f$(1,pos("\"=f$,-1))
!
! Parse out the file
f_file$=f$(pos("\"=f$,-1)+1)
!
! Try to create the old directory - if it exists, then move on
directory f_dir$+"old",err=*next
!
! Close the source file, before trying to move it
close (1,err=*next)
!
! Create a name for the new file and rename the source file
! f_new$=f_dir$+"old\"+dte(0:"%Y%Mz%Dz-%Hz%sz")+".txt" (Slade's orig)
f_new$=f_dir$+"old\"+f_file$
rename f$, f_new$
exit

This version works but the file name must always be the same. Unfortunately, it doesn't work if I use his original statement that's supposed to get the import file name each time: f$=vi2_import_file$

The program errors out in the rename step with "error 10 invalid path". When I go to debug and use ? to ask for each of the variables, they're all as expected except for f$. It's just blank. vi2_import_file$ is also blank. I assume this means it's already forgotten(??) the import file name so perhaps I have the perform mtce screen set up wrong.

Here's what's on the  Perform Maintenance screen:

Perform Type : On Completion

File Type: Standard

Sequence: 001

Command: ..\VI\PL\filerename.pl

I don't see any other way to set up the PM screen - what am I doing wrong?

This a simple AP vendor test job with no other perform logic changes. The client's on v 2014.

Thanks,

Kathy

Parents
  • 0

    This thread helped me, thanks.  I'm now trying to figure out how to incorporate Success/Failure perform logic in v2017, but it appears that functionality is no longer available.  I'm trying to determine other options.  Basically we want to rename/move our VI import source file, but in one manner if the import succeeds, and another manner if it fails.

Reply
  • 0

    This thread helped me, thanks.  I'm now trying to figure out how to incorporate Success/Failure perform logic in v2017, but it appears that functionality is no longer available.  I'm trying to determine other options.  Basically we want to rename/move our VI import source file, but in one manner if the import succeeds, and another manner if it fails.

Children
No Data