Thom,

            I use the system date and time to rename a file (with a .txt extension) created by the DOS DIR command; and I save the renamed file to a ‘history’ location.

            See the attached copies of the *.bat file code and the sub-routine used to do the rename.

 

            What would be *SWEET* would be to NOT have to call the *.bat file, but rather run the directory listing (setting whatever switches are needed) to a file and name the file at the same from within Boston Workstation !!

            ( I’m something of a BWS novice so maybe it IS possible and I just don’t know it yet ).

 

Thanks!

Cris

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Thom C. Blackwell
Sent:
Tuesday, January 24, 2006 5:10 AM
To: [email protected]
Subject: [Talk] "Dynamic" filenames - Suggestions?

 

Greetings,

Hope this message finds all doing well. A quick question for the group…

 

We’re working on a new <Top Secret> J product feature and need some feedback regarding file naming conventions.

 

I know many of you have scripts that cause a system to run and then download some sort of report. Typically part of the script is to name the report file. Some scripts I’ve seen use a static name, others the name is generated by the script and is therefore different each time the script runs.

 

For those of you generating file names “on the fly” in your script – what sort of naming conventions are you using – or would like to use?

Using the system date somehow? Using something else?

 

And what file formats / extensions are you using?

 

Any feedback you can provide will be greatly appreciated!

 

Regards,

Thom

 

Thom C. Blackwell

Product Manager

Boston Software Systems

Visit us at HIMSS Booth 1850

www.BostonWorkStation.com

866 653-5105 - ex 807

[EMAIL PROTECTED]

 

rem (Cris Clausing - October 2005)
rem Creates DIR ectory listing as file named DIRLIST.TXT
rem    NOTE: LIVE location should be the folder in which 
rem          'big files' are created.
E:
CD\sources
DEL dirlist.txt
CD\ps
DIR *.* /o:d >e:\sources\dirlist.txt
EXIT
Sub MoveBIGandBAD()
   ' DIMension / initialize variables used by this sub-routine
   Dim TODAYDate As String, TODAYTime As String, TEXTFile As String, 
DIRLISTExists As String, RENAMETxt As String
   Dim SIZEMaxKB As Double, OLDLocation As String, BIGFileLoc As String, 
BADMARName As String, BADMARLoc As String
   TODAYDate = Format(Date, "yyyymmdd")     ' Current system date.
   TODAYTime = Format(Time, "hhmmss")       ' Current system time.
   TEXTFile = "e:\sources\dirlist.txt"      ' Name of the file created by the 
*.BAT file

   Shell_ "E:\scripts\dir_to_file.bat"      '  Call to *.BAT file for 
DIRrecotory listing of files to *.txt file
   
   Wait 5                                   ' Wait 5 seconds allows time for 
FAT refresh
   DIRLISTExists = ""                       '  Set the intial value as ""
   DIRLISTExists = Dir(TEXTFile)            '  Check to see if the file exits
   Debug.Print DIRLISTExists & " = Yes "    '  Used for debugging
   
   RENAMETxt = "e:\sources\history\dirlist_" & TODAYDate & "_" & TODAYTime & 
".txt"
   
   FileCopy TEXTFile, RENAMETxt            ' Copy the DIR List to the History 
folder with date time stamp in name
   Debug.Print RENAMETxt & " = RENAMETxt"  ' Used for debugging
   
   SIZEMaxKB = 12500000                                                         
  ' MAX KB Size for LIVE location COLD agent = 12,500,000
   OLDLocation = "E:\PS\"                                                       
  ' LIVE location =  e:\PS\
   BIGFileLoc = "e:\bigfiles\"                                                  
  ' Location to which BIG FILES are moved
   Dim OldName, NewName                                                         
  ' Name Statement Variables
   BADMARName = "(Report-Z_MAR_MAR)(MAR)(Name-)(Encounter-)"
   BADMARLoc = "e:\badmars\"                                                    
  ' Location to which BAD MARs are moved

   Dim PSFileSize As Double, PSFileName As String
   D.Open_ TEXTFile, ftFixedLength
   
   Do
     If Trim(D("1")) <> "" And Trim(D("21")) <> "<DIR>" And Trim(D("40")) <> "" 
And Left(D("40"), 1) <> " " Then
       PSFileSize = Trim(D("21"))
       PSFileName = Trim(D("40"))
       If PSFileSize > SIZEMaxKB Then                                           
 ' Move the BIGFiles to their location
         Debug.Print D.Record & " - " & PSFileSize & " - " & PSFileName
         OldName = OLDLocation & PSFileName: NewName = BIGFileLoc & PSFileName  
 ' Set the OLD and NEW Location\Name
         Name OldName As NewName                                                
 ' Move / rename file.
       End If
       If Left(PSFileName, 42) = Left(BADMARName, 42) Then                      
  ' Move the BADMARs to their location
          OldName = OLDLocation & PSFileName: NewName = BADMARLoc & PSFileName  
  ' Set the OLD and NEW Location\Name
          Debug.Print D.Record & " - " & PSFileSize & " - " & PSFileName
          Name OldName As NewName                                               
  ' Move / rename file.
       End If
     End If
       D.Next_
     DoEvents
   Loop Until D.EOF
   
   D.Close_          '  Close the File
   Kill (TEXTFile)   '  Delete the File
   
End Sub ' 
============================================================================================================================

Reply via email to