
He had suggested that our offline email content should be on the forum, and I agreed. As an example of using Movefile to Rename, I provided him with a small sample of using it to keep the last 5 days of an Outlook file. This is stripped down, ignoring paths, etc. It is part of a daily backup routine.
After 5 days of running you will see 5 outlook files in this folder, the current one, outlook.pst, and the copies from the last 5 days, modified names 001 through 005.
//=================================
Let>CF_OVERWRITE=1
Movefile>outlook_004.pst,outlook_005.pst
Movefile>outlook_003.pst,outlook_004.pst
Movefile>outlook_002.pst,outlook_003.pst
Movefile>outlook_001.pst,outlook_002.pst
Copyfile>outlook.pst,outlook_001.pst
//=================================
This simple version can obviously be used for any filenames. And more days can be archived by duplicating the Movefile lines.
That was a sample that I sent to Edward, but he asked for a working copy, so that is provided next.
Here is working code, a more complex version that allows any file name to be archived up to 999 copies. User enters filename, path and number of files to archive. Running daily
//========================================
//Developed by Bob Hansen, 1/5/03
Label>UserVariables
//=============================
//Files will be archived as "filenamebase_nnn.ext" format
//where nnn will be incremented and packed with leading zeroes
//Example: win.ini will become "win_001.ini"
Let>filenamebase=win
Let>Ext=ini
Let>path=c:\windows
//User defined number of copies to archive. Current program will allow up to 999 copies.
Let>copies=15
Label>EndUserVariables
//=============================
Let>CF_OVERWRITE=1
Label>Start
Change Directory>%path%
Let>todo=%copies%
Label>Archive
//=============================
Label>CalcNew
Let>new=00%todo%
Length>%new%,len
If>len=3,CalcOld
If>len=4,Remove1New
Label>Remove2New
//Remove extra zeroes
MidStr>new,3,3,new
Goto>CalcOld
Label>Remove1New
//Remove extra zero
MidStr>new,2,3,new
Label>CalcOld
Let>old=%new%-1
Let>old=00%old%
Length>%old%,len
If>len=3,MakeArchive
If>len=4,Remove1Old
Label>Remove2Old
//Remove extra zeroes
MidStr>old,3,3,old
Goto>MakeArchive
Label>Remove1Old
//Remove extra zero
MidStr>old,2,3,old
Label>MakeArchive
Movefile>%filenamebase%_%old%.%ext%,%filenamebase%_%new%.%ext%
Sub>todo,1
//Check to end archiving
If>%todo%>1,Archive
//Copy current file as most recent archive
Copyfile>%filenamebase%.%ext%,%filenamebase%_001.%ext%
Label>End
//===============================
This routine could also be set up with loops to change the filenames and paths to do this for multiple files in a nightly backup. It is provided as a starting point. Hope it is useful.