Post
by atapper » Mon Jan 19, 2009 8:33 pm
The following is the first part of the script (the rest is pretty much the same and some cleanup operations). It reads the path information from a file called Archive.cfg. The paths look like e:\Data\Forward_Tech\Archive and some other subdirectories. The files that should be moved by this section of code look like 2xxxxxx.dwg
As you can see from the code, I create a .log file that echoes where the MoveFile command should have moved the file from and to.
Another update: I have tried to run the compiled script directly from the server when logged on as admin, but it still doesn't work. And yet it still works on my computer with files on my hard drive. Any ideas would be greatly appreciated.
ReadFile>%SCRIPT_DIR%\Archive.cfg,data_file
Separate>data_file,%CRLF%,rw
Let>Review=%rw_1%
Length>Review,rLen
Let>rLen=rLen+2
Let>Archive=%rw_2%
Let>Old_Archive=%rw_3%
Let>Log=%rw_4%
GetFileList>%Review%\2*.dwg,dwgFile
GetFileList>%Review%\2*.zip,zipFile
Separate>dwgFile,;,dwgFile_name
Separate>zipFile,;,zipFile_name
Let>d=0
Let>z=0
Day>Dy
Month>Mth
Year>Yr
ConCat>Mth,Dy
ConCat>Mth,Yr
/*Move the *.dwg files*/
If>dwgFile_name_countd
Let>d=d+1
Let>Temp=dwgFile_name_%d%
Length>Temp,fLength
MidStr>Temp,rLen,fLength,dwgName
MidStr>dwgName,1,3,dwgStart
Length>dwgName,nLength
Let>NamLen=nLength-4
Let>ExtLen=nLength-3
MidStr>dwgName,1,NamLen,NameOnly
MidStr>dwgName,ExtLen,nLength,Ext
IfFileExists>%Archive%\%dwgStart%\%dwgName%
IfFileExists>%Old_Archive%\%dwgStart%\%NameOnly%_%Mth%%Ext%
DeleteFile>%Old_Archive%\%dwgStart%\%NameOnly%_%Mth%%Ext%
Endif
MoveFile>%Archive%\%dwgStart%\%dwgName%,%Old_Archive%\%dwgStart%\%NameOnly%_%Mth%%Ext%
WriteLn>%Log%\ArchiveLog_%Mth%.txt,nWLNRes,%Archive%\%dwgStart%\%dwgName% was moved to %Old_Archive%\%dwgStart%\%NameOnly%_%Mth%%Ext%
EndIf
MoveFile>Temp,%Archive%\%dwgStart%\%dwgName%
WriteLn>%Log%\ArchiveLog_%Mth%.txt,nWLNRes,%Temp% was moved to %Archive%\%dwgStart%\%dwgName%
Until>d,dwgFile_name_count
EndIf
Andrew Tapper
Engineering Manager
Forward Technology
Cokato, MN