copyfile and movefile won't work in middle of script

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

copyfile and movefile won't work in middle of script

Post by kpassaur » Sun Feb 26, 2006 4:23 pm

I have a script where I want to move a file to a folder then copy it into a folder for backup.

If I write a script that just does that it works. however, it is part of a larger script and it does not work. I have written the move file command line to a text file to see what I was missing and I cannot find anything wrong with it.

I thought it was maybe something with the variables so I assigned values manually just before the movefile and copyfile and it did not work. I copied this section into a new script and it did work. It appears that some other action in the script is disabling these features. I'm sure I'm wrong on this part, but I am at a loss.




COF

/////////////////////////////////////////// Move the File /////////////////////////////////////////
Label>Moveit
Let>z=1
Label>start
ReadLn>c:\FaxRouter\folderlist.txt,z,linetoparse
If>%linetoparse%=##EOF##,%nofolderfound%
Let>z=z+1
Let>key={Pos("-",%linetoparse%)}
Let>lookupkey={copy(%linetoparse%,1,%key%-1)}
If>%Dialog1.Shortcut%=%lookupkey%,matched,trymatchagain

Label>trymatchagain
Goto>start
Label>matched

/////////////get last part of Folder Name
Len>%linetoparse%,lenoflinetoparse
Let>folderpart={Copy(%linetoparse%,%key%+1,%lenoflinetoparse%)}
Goto>havefolder

Label>nofolderfound
Let>INPUT_BROWSE=0
Input>folderpart,No Match was not found for %Dialog1.Shortcut% Please enter a folder for %Dialog1.Shortcut%
WriteLN>c:\FaxRouter\folderlist.txt,,%Dialog1.Shortcut%-%newfolder%

Label>havefolder
IfDirExists>%folderpart%
MDL>The Folder %folderpart% exists
Goto>havedir
Endif
MDL>Create this dir %folderpart%
CreateDir>%folderpart%

Label>havedir

/MDL>the filename is %filename%

/Let>fpath=c:\faxesin
/Let>ppath=C:\processedfaxes
/Let>filename=123DONMERLO-APPROVAL.tif
/Let>folderpart=C:\processedfaxes\Keith
WriteLN>C:\processedfaxes\testit.txt,,%fpath%\%filename%,%ppath%\%filename%

MoveFile>%fpath%\%filename%,%ppath%\%filename%
CopyFile>%ppath%\%filename%,%folderpart%\%filename%

Goto>donewithimage
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// Email the File /////////////////////////////////////////




The line written is

c:\faxesin\123DONMERLO-APPROVAL.tif,C:\processedfaxes\123DONMERLO-APPROVAL.tif


Any ideas


kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Another Example of MoveFile

Post by kpassaur » Sun Feb 26, 2006 5:21 pm

The script below reads the text file and should move then copy the files. The files and folders exist. If I copy the message line, paste it at the bottom of the script and execute it the line works. Why won't it just process every line?


Iffileexists>c:\FaxRouter\postprocessfiles.txt
Let>x=1
Label>startfileprocess
ReadLn>c:\FaxRouter\postprocessfiles.txt,x,linetoprocess
If>line=##EOF##,finishfileprocess
MDL>%linetoprocess%
/MoveFile>%linetoprocess%
/CopyFile>%linetoprocess%
Let>x=x+1
Goto>startfileprocess
Label>finishfileprocess
DeleteFile>c:\FaxRouter\postprocessfiles.txt

MoveFile>c:\faxesin\98-0100-INCOME-DOCS.tif,c:\processedfaxes\98-0100-INCOME-DOCS.tif

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sun Feb 26, 2006 10:11 pm

Some observations:

1. Iffileexists> needs a Ttue/False branch
2. If>Line=.... should be If>linetoprocess=........
3. /Move will not work
4. /Copy will not work
5. Should Copy before Move, else source to copy from has been moved and does not exist any longer.

Biggest issue is probably ovservation #2.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Thanks Bob

Post by kpassaur » Sun Feb 26, 2006 10:52 pm

I caught the bit on line two and regardless I cannot get movefile to work. So what I ended up with was copying the file twice and then deleting it.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts