csd158 Posted March 2, 2009 Posted March 2, 2009 Wondering if someone could help with the following batch file...I would like it to keep a running log of dates. Now it overwrites the previous day, any help would be greatly appreciated. Thanks.REM Start by setting the location to store the backup and the drive PowerSchool data resides on SET POWERSCHOOL_SCRIPTS=D:SET POWERSCHOOL_DRIVE=D:SET POWERSCHOOL_BACKUP_FOLDER=D:\DailyBackup\IF NOT EXIST %POWERSCHOOL_BACKUP_FOLDER% MD %POWERSCHOOL_BACKUP_FOLDER%REM Capture the 3-character name of todaySET DAY=DefaultFOR /F "TOKENS=1" %%A IN ('DATE/T') DO SET DAY=%%AREM Sets the drive letter%POWERSCHOOL_DRIVE%Cd oradata\psproddb\data_pump_dir\IF EXIST PowerSchool-%DAY%.dmp erase PowerSchool-%DAY%.dmp /q%POWERSCHOOL_SCRIPTS%cd\Cd oracle\scriptscall EXPORT PSProdDB PowerSchool-%DAY%%POWERSCHOOL_DRIVE%Cd\Cd oradata\psproddb\data_pump_dir\Copy PowerSchool-%DAY%.dmp %POWERSCHOOL_BACKUP_FOLDER% /YThanks again,csd158
Yzöwl Posted March 2, 2009 Posted March 2, 2009 I'm guessing that your particular setup outputs DOW as part of Date/T, therefore every seven days you'll be overwriting the previous file. I'd suggest therefore that you use the full date instead, preferably in standard format or similar. YYYYMMDD.
csd158 Posted March 3, 2009 Author Posted March 3, 2009 Thank you for the reply. So would I replace that line with:for /F "tokens=2-4 delims=/ " %i in ('date /t') do %k%i%jI appreciate your help,csd158
Yzöwl Posted March 3, 2009 Posted March 3, 2009 I have no idea what your system outputs for DATE/TMine outputs:DD/MM/YYYY
gunsmokingman Posted March 4, 2009 Posted March 4, 2009 Try this VBS Script it just list the contents of D:\DailyBackup\, I have also included some date varibles. I have not included any code to copy or delete any files. If it list the files that you want to copy or delete, post the file name and what you want done with it. I will then add the code to this script.Save As MyBackup.vbsOption Explicit Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim A1,Dy1, Dy2, Dy, Mn1, Mn2, Mn, Ts, Yr'-> Date Varibles Dy = Day(Now) Dy1 = WeekdayName(Dy, True) Dy2 = WeekdayName(Dy, False) Mn = Month(Now) Mn1 = MonthName(Mn, True) Mn2 = MonthName(Mn, False) Yr = Year(Now)'-> If Varibles Are Less Then 10 Add A Zero If Len(Dy) < 2 Then Dy = "0" & Dy If Len(Mn) < 2 Then Mn = "0" & Mn A1 = Mn & "_" & Mn1 & "_" & Dy1 & "_" & Dy '-> Location Varibles Dim Loc :Loc = "D:\DailyBackup\" Dim Rpt :Rpt = Act.SpecialFolders("Desktop") & "\" & Yr & "_" & A1 & "_DailyBackup.log" '-> Check To See If The Folder Exists If Fso.FolderExists(Loc) Then Set Ts = Fso.CreateTextFile(Rpt) Ts.WriteLine Vbtab & "Date Varibles" Ts.WriteLine _ " Dy = " & Dy & vbCrLf & _ " Dy1 = " & Dy1 & vbCrLf & _ " Dy2 = " & Dy2 & vbCrLf & _ " Mn = " & Mn & vbCrLf & _ " Mn1 = " & Mn1 & vbCrLf & _ " Mn2 = " & Mn2 & vbCrLf & _ " Yr = " & Yr & vbCrLf Ts.WriteLine " Computer Name : " & Act.ExpandEnvironmentStrings("%ComputerName%") Ts.WriteLine " Log File Name 1 : " & Rpt Ts.WriteLine " Log File Name 2 : " & Replace(Rpt, A1, Mn2 & "_" & Dy2) & vbCrLf Ts.WriteLine Space(5) & " Start Folder " & Loc'-> Get Parent Folder And Sub Folder And All Files SubFolder Fso.GetFolder(Loc) Ts.Close Act.Run("Notepad.exe " & Chr(34) & Rpt & Chr(34)),1,true End If '-> Process The Folder Function SubFolder(Folder) Dim Col, File For Each File In Folder.files Ts.WriteLine " File Name : " & File.Path Next For Each Col In Folder.subFolders Ts.WriteLine Vbcrlf & Space(5) & " Sub Folder : " & Col.Path SubFolder Col Next End Function
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now