ammartahir1978
asked on
how to change the file name and add alert
Hi All
I have this script which change for dates and change them.
I want to add two things:
1. Can we rename the file to A<date>_Orderno_Time.csv ( order number is the second field in the file)
2. it reads all the files in the folder can a message alert be added to show its been processed?
Thank you for your help.
I have this script which change for dates and change them.
I want to add two things:
1. Can we rename the file to A<date>_Orderno_Time.csv ( order number is the second field in the file)
2. it reads all the files in the folder can a message alert be added to show its been processed?
Thank you for your help.
Option Explicit
' ==============================================================================
' C O N S T A N T S & V A R I A B L E S
' ==============================================================================
' Define needed constants
Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2
' Define global variables
Dim objFSO
Dim strCheckFolder
' Specify path to folder of files to process
strCheckFolder = "D:\LABELS\ChessODBCFiles\BedfordSO"
' ==============================================================================
' I N I T I A L I Z A T I O N
' ==============================================================================
' Create filesystem object
Set objFSO = CreateObject("Scripting.FileSystemObject")
' ==============================================================================
' M A I N L O G I C
' ==============================================================================
' Process the base folder
ProcessFolder strCheckFolder
' ==============================================================================
' W R A P U P
' ==============================================================================
' Done, cleanup and exit
Wscript.Quit
' ==============================================================================
' S U B R O U T I N E S & F U N C T I O N S
' ==============================================================================
Sub ProcessFolder(strCheckFolder)
' Define local variables
Dim objCheckFolder
Dim objCheckFile
' Make sure the folder exists
If Not objFSO.FolderExists(strCheckFolder) Then
Wscript.Echo "*ERROR* Folder [" & strCheckFolder & "] does not exist, quitting."
Wscript.Quit
End If
' Access the folder
Set objCheckFolder = objFSO.GetFolder(strCheckFolder)
' Look at all files in this folder, process each one
For Each objCheckFile In objCheckFolder.Files
ProcessFile objCheckFile
Next
End Sub
Sub ProcessFile(objCheckFile)
' Define local varaibles
Dim objFile
Dim strData
Dim arrLines
Dim arrFields
Dim blnFileChanged
Dim i
Dim datNextFutureWorkingDay
Dim strDelim
' Read the file contents into an array for processing
Set objFile = objFSO.OpenTextFile(objCheckFile.Path, ForReading, False, TriStateUseDefault)
strData = objFile.ReadAll
objFile.Close
Set objFile = Nothing
' Determine what is used in the file for line delimiters, and split file into lines
If InStr(strData, vbCrLf) > 0 Then
strDelim = vbCrLf
ElseIf InStr(strData, vbLf) > 0 Then
strDelim = vbLf
ElseIf InStr(strData, vbCr) > 0 Then
strDelim = vbCr
End If
arrLines = Split(strData, strDelim)
' Assume no changes needed to this file
blnFileChanged = False
' Look at each line of the file and check the date field
For i = 0 To UBound(arrLines)
' Split the fields of this line apart into an array (comma delim)
arrFields = Split(arrLines(i), ",")
' Make sure we found at least 7 columns (array indexes are 0 based...)
If UBound(arrFields) > 5 Then
' Check if 7th column is in the future, if not set it to tomorrows date
datNextFutureWorkingDay = NextFutureWorkingDay()
If DateDiff("d", datNextFutureWorkingDay, StringToDate(Trim(arrFields(6)))) < 0 Then
arrFields(6) = DateToString(datNextFutureWorkingDay)
arrLines(i) = Join(arrFields, ",")
blnFileChanged = True
End If
End If
Next
' If we changed any data in the file, then rewrite it now
If blnFileChanged Then
strData = Join(arrLines, vbCrLf)
Set objFile = objFSO.OpenTextFile(objCheckFile.Path, ForWriting, True)
objFile.Write(strData)
objFile.Close
Set objFile = Nothing
End If
End Sub
Function NextFutureWorkingDay()
' Calculate the next working day (no weekends, no holidays) in the future
NextFutureWorkingDay = DateAdd("d", 1, Now)
Do Until (Weekday(NextFutureWorkingDay) <> vbSaturday) And (Weekday(NextFutureWorkingDay) <> vbSunday) And (Not IsHoliday(NextFutureWorkingDay))
NextFutureWorkingDay = DateAdd("d", 1, NextFutureWorkingDay)
Loop
End Function
Function StringToDate(strDate)
' Convert a string inb format YYYYMMDD to a date type value
StringToDate = CDate(Mid(strDate, 5, 2) & "/" & Mid(strDate, 7, 2) & "/" & Mid(strDate, 1, 4))
End Function
Function DateToString(datDate)
' Convert a date type value to a text string in format YYYYMMDD
DateToString = Year(datDate) & LPad(Month(datDate), 2, "0") & LPad(Day(datDate), 2, "0")
End Function
Function LPad( strText, intLen, chrPad )
' Left pad a string to any length with a specified character
LPad = Right( String( intLen, chrPad ) & strText, intLen )
End Function
Function IsHoliday(dDate)
'Checks to see if passed date is a holiday
Dim iDay, iTmpDay, i
IsHoliday = 0
iDay = Day(dDate)
'Check if valid date first
If IsDate(dDate) Then
Select Case Month(dDate)
Case 1 'Jan
If iDay = 1 Then 'New Years
IsHoliday = 1
Else
If iDay = 2 Then 'Make sure new years doesn't fall on sunday.
'If so, today is a holiday.
If Weekday(DateAdd("d", -1, dDate)) = 1 Then
IsHoliday = 1
End If
Else
For i = 0 To 30 'Martin Luther King B-Day
If Weekday(DateAdd("d", i, CDate("1/1/" & Year(dDate)))) _
= 2 Then
If CDate(dDate) = CDate(DateAdd("d", i + 14, _
CDate("1/1/" & Year(dDate)))) Then
IsHoliday = 1
End If
Exit For 'PG 1/28
End If
Next
End If
End If
Case 2 'Feb
For i = 0 To 27 'President's Day
If Weekday(DateAdd("d", i, CDate("2/1/" & Year(dDate)))) = 2 _
Then
If CDate(dDate) = CDate(DateAdd("d", i + 14, _
CDate("2/1/" & Year(dDate)))) Then
IsHoliday = 1
End If
Exit For
End If
Next
Case 3 'Mar
Case 4 'Apr
Case 5 'May
For i = 1 To 7 'Memorial Day
If Weekday(DateAdd("d", "-" & i, _
CDate("5/31/" & Year(dDate)))) = 2 Then
If CDate(dDate) = CDate(DateAdd("d", "-" & i, _
CDate("5/31/" & Year(dDate)))) Then
IsHoliday = 1
End If
Exit For
End If
Next
Case 6 'Jun
Case 7 'Jul
If iDay = 4 Then 'Independence Day
IsHoliday = 1
Else
If iDay = 3 Then 'Make sure Independence Day doesn't
'fall on saturday. If so, Friday is a holiday.
If Weekday(DateAdd("d", 1, dDate)) = 7 Then
IsHoliday = 1
End If
Else
If iDay = 5 Then 'Make sure Independence
'Day doesn't fall on sunday. If so, Monday is a holiday.
If Weekday(DateAdd("d", -1, dDate)) = 1 Then
IsHoliday = 1
End If
End If
End If
End If
Case 8 'Aug
Case 9 'Sep
For i = 0 To 13 'Labor Day
If Weekday(DateAdd("d", i, CDate("9/1/" & _
Year(dDate)))) = 2 Then
If CDate(dDate) = CDate(DateAdd("d", i, _
CDate("9/1/" & Year(dDate)))) Then
IsHoliday = 1
End If
Exit For
End If
Next
Case 10 'Oct
For i = 0 To 13 'Columbus Day
If Weekday(DateAdd("d", i, CDate("10/1/" & _
Year(dDate)))) = 2 Then
If CDate(dDate) = CDate(DateAdd("d", i + 7, CDate("10/1/" & _
Year(dDate)))) Then
IsHoliday = 1
End If
Exit For
End If
Next
Case 11 'Nov
If iDay = 11 Then 'Veteran's Day
IsHoliday = 1
Else
If iDay = 10 Then 'Make sure Veterans Day doesn't fall
'on saturday. If so, Friday is a holiday.
If Weekday(DateAdd("d", 1, dDate)) = 7 Then
IsHoliday = 1
End If
Else
If iDay = 12 Then 'Make sure Veterans Day doesn't
'fall on sunday. If so, Monday is a holiday.
If Weekday(DateAdd("d", -1, dDate)) = 1 Then
IsHoliday = 1
End If
Else
For i = 0 To 28 'Thanksgiving & the Day After
If Weekday(DateAdd("d", i, CDate("11/1/" & _
Year(dDate)))) = 5 Then 'this is the first
'thursday of the month
If DateDiff("d", dDate, DateAdd("d", i + 21, _
CDate("11/1/" & Year(dDate)))) = 0 Then 'add 3
'weeks to the first to get the 4th (thanksgiving)
IsHoliday = 1
Exit For
End If
End If
If Weekday(DateAdd("d", i, CDate("11/1/" & _
Year(dDate)))) = 6 Then 'this is the day
'after thanksgiving
If DateDiff("d", dDate, DateAdd("d", i + 21, CDate("11/1/" & Year(dDate)))) = 0 Then
IsHoliday = 1
Exit For
End If
End If
Next
End If
End If
End If
Case 12 'Dec
If iDay = 25 Then 'Christmas
IsHoliday = 1
Else
If iDay = 24 Then 'Make sure Christmas Day doesn't
'fall on saturday. If so, Friday is a holiday.
If Weekday(DateAdd("d", 1, dDate)) = 7 Then
IsHoliday = 1
End If
Else
If iDay = 26 Then 'Make sure Christmas
'Day doesn't fall on sunday. If so, Monday is a holiday.
If Weekday(DateAdd("d", -1, dDate)) = 1 Then
IsHoliday = 1
End If
Else
If iDay = 31 Then 'Make sure new years
'doesn't fall on saturday. If so, today is a holiday.
If Weekday(DateAdd("d", 1, dDate)) = 7 Then
IsHoliday = 1
End If
End If
End If
End If
End If
Case Else
'Do nothing but return false
End Select
End If
End Function
ASKER
Hi Bill,
well spotted thank you.
I want file name to be
A20160816_082104_CHESSPL.C SV to A20160816_<ORDERNO>_CHESSP L.CSV
yes doesnt matter if contents are changed or not file name should change.
Thank you
well spotted thank you.
I want file name to be
A20160816_082104_CHESSPL.C
yes doesnt matter if contents are changed or not file name should change.
Thank you
Give this a test and see how you like it. Â I added a few messages along the way in the processing of each file, these can be adjusted as needed.
Option Explicit
' ==============================================================================
' C O N S T A N T S & V A R I A B L E S
' ==============================================================================
' Define needed constants
Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2
' Define global variables
Dim objFSO
Dim strCheckFolder
' Specify path to folder of files to process
strCheckFolder = "D:\LABELS\ChessODBCFiles\BedfordSO"
' ==============================================================================
' I N I T I A L I Z A T I O N
' ==============================================================================
' Create filesystem object
Set objFSO = CreateObject("Scripting.FileSystemObject")
' ==============================================================================
' M A I N L O G I C
' ==============================================================================
' Process the base folder
ProcessFolder strCheckFolder
' ==============================================================================
' W R A P U P
' ==============================================================================
' Done, cleanup and exit
Wscript.Quit
' ==============================================================================
' S U B R O U T I N E S & F U N C T I O N S
' ==============================================================================
Sub ProcessFolder(strCheckFolder)
' Define local variables
Dim objCheckFolder
Dim objCheckFile
' Make sure the folder exists
If Not objFSO.FolderExists(strCheckFolder) Then
Wscript.Echo "*ERROR* Folder [" & strCheckFolder & "] does not exist, quitting."
Wscript.Quit
End If
' Access the folder
Set objCheckFolder = objFSO.GetFolder(strCheckFolder)
' Look at all files in this folder, process each one
For Each objCheckFile In objCheckFolder.Files
ProcessFile objCheckFile
Next
End Sub
Sub ProcessFile(objCheckFile)
' Define local varaibles
Dim objFile
Dim strData
Dim arrLines
Dim arrFields
Dim blnFileChanged
Dim i
Dim datNextFutureWorkingDay
Dim strDelim
Dim strOrder
Wscript.Echo "Checking file [" & objCheckFile.Name & "]."
' Read the file contents into an array for processing
Set objFile = objFSO.OpenTextFile(objCheckFile.Path, ForReading, False, TriStateUseDefault)
strData = objFile.ReadAll
objFile.Close
Set objFile = Nothing
' Determine what is used in the file for line delimiters, and split file into lines
If InStr(strData, vbCrLf) > 0 Then
strDelim = vbCrLf
ElseIf InStr(strData, vbLf) > 0 Then
strDelim = vbLf
ElseIf InStr(strData, vbCr) > 0 Then
strDelim = vbCr
End If
arrLines = Split(strData, strDelim)
' Assume no changes needed to this file
blnFileChanged = False
strOrder = ""
' Look at each line of the file and check the date field
For i = 0 To UBound(arrLines)
' Split the fields of this line apart into an array (comma delim)
arrFields = Split(arrLines(i), ",")
' Get order number from first line of data file
If strOrder = "" Then
strOrder = Trim(arrFields(1))
End If
' Make sure we found at least 7 columns (array indexes are 0 based...)
If UBound(arrFields) > 5 Then
' Check if 7th column is in the future, if not set it to tomorrows date
datNextFutureWorkingDay = NextFutureWorkingDay()
If DateDiff("d", datNextFutureWorkingDay, StringToDate(Trim(arrFields(6)))) < 0 Then
arrFields(6) = DateToString(datNextFutureWorkingDay)
arrLines(i) = Join(arrFields, ",")
blnFileChanged = True
End If
End If
Next
' If we changed any data in the file, then rewrite it now
If blnFileChanged Then
Wscript.Echo " Dates updated in [" & objCheckFile.Name & "]."
strData = Join(arrLines, vbCrLf)
Set objFile = objFSO.OpenTextFile(objCheckFile.Path, ForWriting, True)
objFile.Write(strData)
objFile.Close
Set objFile = Nothing
Else
Wscript.Echo " No dates to update in [" & objCheckFile.Name & "]."
End If
' Rename file with order number
Wscript.Echo " Renaming file from [" & objCheckFile.Name & "] to [" & NewFileName(objCheckFile.Name, strOrder) & "]."
objCheckFile.Name = NewFileName(objCheckFile.Name, strOrder)
End Sub
Function NewFileName(strName, strOrder)
Dim arrTokens
arrTokens = Split(strName, "_")
NewFileName = arrTokens(0) & "_" & strOrder & "_" & arrTokens(2)
End Function
Function NextFutureWorkingDay()
' Calculate the next working day (no weekends, no holidays) in the future
NextFutureWorkingDay = DateAdd("d", 1, Now)
Do Until (Weekday(NextFutureWorkingDay) <> vbSaturday) And (Weekday(NextFutureWorkingDay) <> vbSunday) And (Not IsHoliday(NextFutureWorkingDay))
NextFutureWorkingDay = DateAdd("d", 1, NextFutureWorkingDay)
Loop
End Function
Function StringToDate(strDate)
' Convert a string inb format YYYYMMDD to a date type value
StringToDate = CDate(Mid(strDate, 5, 2) & "/" & Mid(strDate, 7, 2) & "/" & Mid(strDate, 1, 4))
End Function
Function DateToString(datDate)
' Convert a date type value to a text string in format YYYYMMDD
DateToString = Year(datDate) & LPad(Month(datDate), 2, "0") & LPad(Day(datDate), 2, "0")
End Function
Function LPad( strText, intLen, chrPad )
' Left pad a string to any length with a specified character
LPad = Right( String( intLen, chrPad ) & strText, intLen )
End Function
Function IsHoliday(dDate)
'Checks to see if passed date is a holiday
Dim iDay, iTmpDay, i
IsHoliday = 0
iDay = Day(dDate)
'Check if valid date first
If IsDate(dDate) Then
Select Case Month(dDate)
Case 1 'Jan
If iDay = 1 Then 'New Years
IsHoliday = 1
Else
If iDay = 2 Then 'Make sure new years doesn't fall on sunday.
'If so, today is a holiday.
If Weekday(DateAdd("d", -1, dDate)) = 1 Then
IsHoliday = 1
End If
Else
For i = 0 To 30 'Martin Luther King B-Day
If Weekday(DateAdd("d", i, CDate("1/1/" & Year(dDate)))) _
= 2 Then
If CDate(dDate) = CDate(DateAdd("d", i + 14, _
CDate("1/1/" & Year(dDate)))) Then
IsHoliday = 1
End If
Exit For 'PG 1/28
End If
Next
End If
End If
Case 2 'Feb
For i = 0 To 27 'President's Day
If Weekday(DateAdd("d", i, CDate("2/1/" & Year(dDate)))) = 2 _
Then
If CDate(dDate) = CDate(DateAdd("d", i + 14, _
CDate("2/1/" & Year(dDate)))) Then
IsHoliday = 1
End If
Exit For
End If
Next
Case 3 'Mar
Case 4 'Apr
Case 5 'May
For i = 1 To 7 'Memorial Day
If Weekday(DateAdd("d", "-" & i, _
CDate("5/31/" & Year(dDate)))) = 2 Then
If CDate(dDate) = CDate(DateAdd("d", "-" & i, _
CDate("5/31/" & Year(dDate)))) Then
IsHoliday = 1
End If
Exit For
End If
Next
Case 6 'Jun
Case 7 'Jul
If iDay = 4 Then 'Independence Day
IsHoliday = 1
Else
If iDay = 3 Then 'Make sure Independence Day doesn't
'fall on saturday. If so, Friday is a holiday.
If Weekday(DateAdd("d", 1, dDate)) = 7 Then
IsHoliday = 1
End If
Else
If iDay = 5 Then 'Make sure Independence
'Day doesn't fall on sunday. If so, Monday is a holiday.
If Weekday(DateAdd("d", -1, dDate)) = 1 Then
IsHoliday = 1
End If
End If
End If
End If
Case 8 'Aug
Case 9 'Sep
For i = 0 To 13 'Labor Day
If Weekday(DateAdd("d", i, CDate("9/1/" & _
Year(dDate)))) = 2 Then
If CDate(dDate) = CDate(DateAdd("d", i, _
CDate("9/1/" & Year(dDate)))) Then
IsHoliday = 1
End If
Exit For
End If
Next
Case 10 'Oct
For i = 0 To 13 'Columbus Day
If Weekday(DateAdd("d", i, CDate("10/1/" & _
Year(dDate)))) = 2 Then
If CDate(dDate) = CDate(DateAdd("d", i + 7, CDate("10/1/" & _
Year(dDate)))) Then
IsHoliday = 1
End If
Exit For
End If
Next
Case 11 'Nov
If iDay = 11 Then 'Veteran's Day
IsHoliday = 1
Else
If iDay = 10 Then 'Make sure Veterans Day doesn't fall
'on saturday. If so, Friday is a holiday.
If Weekday(DateAdd("d", 1, dDate)) = 7 Then
IsHoliday = 1
End If
Else
If iDay = 12 Then 'Make sure Veterans Day doesn't
'fall on sunday. If so, Monday is a holiday.
If Weekday(DateAdd("d", -1, dDate)) = 1 Then
IsHoliday = 1
End If
Else
For i = 0 To 28 'Thanksgiving & the Day After
If Weekday(DateAdd("d", i, CDate("11/1/" & _
Year(dDate)))) = 5 Then 'this is the first
'thursday of the month
If DateDiff("d", dDate, DateAdd("d", i + 21, _
CDate("11/1/" & Year(dDate)))) = 0 Then 'add 3
'weeks to the first to get the 4th (thanksgiving)
IsHoliday = 1
Exit For
End If
End If
If Weekday(DateAdd("d", i, CDate("11/1/" & _
Year(dDate)))) = 6 Then 'this is the day
'after thanksgiving
If DateDiff("d", dDate, DateAdd("d", i + 21, CDate("11/1/" & Year(dDate)))) = 0 Then
IsHoliday = 1
Exit For
End If
End If
Next
End If
End If
End If
Case 12 'Dec
If iDay = 25 Then 'Christmas
IsHoliday = 1
Else
If iDay = 24 Then 'Make sure Christmas Day doesn't
'fall on saturday. If so, Friday is a holiday.
If Weekday(DateAdd("d", 1, dDate)) = 7 Then
IsHoliday = 1
End If
Else
If iDay = 26 Then 'Make sure Christmas
'Day doesn't fall on sunday. If so, Monday is a holiday.
If Weekday(DateAdd("d", -1, dDate)) = 1 Then
IsHoliday = 1
End If
Else
If iDay = 31 Then 'Make sure new years
'doesn't fall on saturday. If so, today is a holiday.
If Weekday(DateAdd("d", 1, dDate)) = 7 Then
IsHoliday = 1
End If
End If
End If
End If
End If
Case Else
'Do nothing but return false
End Select
End If
End Function
~bp
ASKER
Hi Bill that is great, can these messages be only for where there is a change or a log file which says
file name changed to newfilename and despatch date change from <Olddate> to <New date>
the reason i am asking is becasue with these alerts i wont be able to run it via schedule task?
file name changed to newfilename and despatch date change from <Olddate> to <New date>
the reason i am asking is becasue with these alerts i wont be able to run it via schedule task?
So do you always want a line showing the name change of the file? Â Or only if there were date changes in it?
And then in addition you want one line for every line of a file that had a date change?
~bp
And then in addition you want one line for every line of a file that had a date change?
~bp
ASKER
no no no
all i want is if the script run :
it changes the file name doesnt matter there is date change or not but if there is a date change it can log it separately in a log file i think you are the expert i will go with your recommendation.
all i want is if the script run :
it changes the file name doesnt matter there is date change or not but if there is a date change it can log it separately in a log file i think you are the expert i will go with your recommendation.
We can have it log whatever you like, I just want to settle on what that is before I code it, rather than having to change it several times. Â Let me see if I can clarify.
You only want to log when a line of a data file is changed, and you want to include the filename in the log, as well as the old date and new date that was changed? Â I would also suggest we add the line number to this message.
Do you want these message written to a file, and if so how do you want this log file named? Â Should the file be added to each time the script runs, or should a new log file be created from empty? Â Do you want the current date/time as part of the log file name, or the same file name used each time?
~bp
You only want to log when a line of a data file is changed, and you want to include the filename in the log, as well as the old date and new date that was changed? Â I would also suggest we add the line number to this message.
Do you want these message written to a file, and if so how do you want this log file named? Â Should the file be added to each time the script runs, or should a new log file be created from empty? Â Do you want the current date/time as part of the log file name, or the same file name used each time?
~bp
ASKER
You are right in what i need.
log file can be created in log folder of the path which will end BedfordSO\Log and file can be created for a day so one file each day with the Datestamp.
log file can be created in log folder of the path which will end BedfordSO\Log and file can be created for a day so one file each day with the Datestamp.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
thanks Bill this is perfect can i add the timestamp in log file? so i can identify what time which file was edited or amended?
File newname:"A20160816_2121382_CHESSPL.C SV", oldname:"A20160816_103569_ CHESSPL.CS V", line:1, olddate:20160817, newdate:20160818
File newname:"A20160816_2121351_CHESSPL.C SV", oldname:"A20160816_105115_ CHESSPL.CS V", line:1, olddate:20160817, newdate:20160818
File newname:"A20160816_2121351_CHESSPL.C SV", oldname:"A20160816_105115_ CHESSPL.CS V", line:2, olddate:20160817, newdate:20160818
File newname:"A20160816_2121351_CHESSPL.C SV", oldname:"A20160816_105115_ CHESSPL.CS V", line:3, olddate:20160817, newdate:20160818
File newname:"A20160816_2121351_CHESSPL.C SV", oldname:"A20160816_105115_ CHESSPL.CS V", line:4, olddate:20160817, newdate:20160818
File newname:"A20160816_2121351_CHESSPL.C SV", oldname:"A20160816_105115_ CHESSPL.CS V", line:5, olddate:20160817, newdate:20160818
File newname:"A20160816_2121351_CHESSPL.C SV", oldname:"A20160816_105115_ CHESSPL.CS V", line:6, olddate:20160817, newdate:20160818
File newname:"A20160816_2121331_CHESSPL.C SV", oldname:"A20160816_11254_C HESSPL.CSV ", line:1, olddate:20160817, newdate:20160818
File newname:"A20160816_2121331_CHESSPL.C SV", oldname:"A20160816_11254_C HESSPL.CSV ", line:2, olddate:20160817, newdate:20160818
File newname:"A20160816_2121490_CHESSPL.C SV", oldname:"A20160816_114852_ CHESSPL.CS V", line:1, olddate:20160815, newdate:20160818
File newname:"A20160816_2121490_CHESSPL.C SV", oldname:"A20160816_114852_ CHESSPL.CS V", line:2, olddate:20160817, newdate:20160818
File newname:"A20160816_2121433_CHESSPL.C SV", oldname:"A20160816_115125_ CHESSPL.CS V", line:1, olddate:20160817, newdate:20160818
File newname:"A20160816_2121433_CHESSPL.C SV", oldname:"A20160816_115125_ CHESSPL.CS V", line:2, olddate:20160817, newdate:20160818
File newname:"A20160816_2121433_CHESSPL.C SV", oldname:"A20160816_115125_ CHESSPL.CS V", line:3, olddate:20160817, newdate:20160818
File newname:"A20160816_2121466_CHESSPL.C SV", oldname:"A20160816_125458_ CHESSPL.CS V", line:1, olddate:20160817, newdate:20160818
File newname:"A20160816_2121466_CHESSPL.C SV", oldname:"A20160816_125458_ CHESSPL.CS V", line:2, olddate:20160817, newdate:20160818
File newname:"A20160816_2121490_CHESSPL.C SV", oldname:"A20160816_110254_ CHESSPL.CS V", line:1, olddate:20160817, newdate:20160818
File newname:"A20160816_2121490_CHESSPL.C SV", oldname:"A20160816_110254_ CHESSPL.CS V", line:2, olddate:20160817, newdate:20160818
ASKER
He is the best expert on EE i would like to hire Bill and i think i will soon THANK YOU VERY MUCH SO ALL YOUR HELP AND SUPPORT.
Yes, adjust line 128 as follows:
objLogFile.WriteLine Now() & " - File newname:""" & strNewFileName & """, oldname:""" & objCheckFile.Name & """, line:" & i+1 & ", olddate:" & arrFields(6) & ", newdate:" & DateToString(datNextFutureWorkingDay)
~bp
ASKER
HI Bill,
The script is missing some files without changing the date, i had 6 files which got missed, is there anything you can do?
The script is missing some files without changing the date, i had 6 files which got missed, is there anything you can do?
Can you provide the files that were not processed, and the date you fan the script please.
~bp
~bp
I ran a test with this data line:
W,2117626,CI/1940000/9148,0001/2117626/001,RICHARD ROURKE ,20160808,20160809,0001/2117626/001,0100,343921WT,1 ,1 ,UNIT,C
and it did change the date, and this was logged:8/19/2016 8:18:18 AM - File newname:"A20160815_2117626_CHESSPL.CSV", oldname:"A20160815_184101_CHESSPL.CSV", line:1, olddate:20160809, newdate:20160822
~bp
ASKER
i dont know when i run the script it missed 6-10 files but i know you are right must be something else.
I have emailed you as well
I have emailed you as well
A20160816_082104_CHESSPL.C
Do you want to use the date and time from the existing file name, and add the order number from the contents of the file, or do you want a new data and time to be used that is the date and time when the script was executed?
If the file contents are not changed, do you still want the file name changed anyway?
~bp