'Invalid file extension
Public Function fnFileInvalidExtn(strfolderSourcePath,strfolderdestnPath,strFile)
Set FSO=CreateObject("Scripting.FileSystemObject")
strfolderSourcePath_mod=strfolderSourcePath&"\"&strFile
strTestFileName1=Split (strFile,".")
strTestFileNameFir=strTestFileName1(0)
strTestFileName_extn_chg=strTestFileNameFir&"."&"d"
strfolderdestnPath_mod=strfolderdestnPath&"\"&strTestFileName_extn_chg
FileEx=FSO.FileExists(strfolderSourcePath_mod)
If FileEx=True Then
FSO.MoveFile strfolderSourcePath_mod,strfolderdestnPath_mod
Call fnDoneResult("File Extension changed is Sucessful","File is renamed to " & strfolderdestnPath)
else
Call fnFailResult("File Extension changed is UnSucessful ","Unable to renamed file to " & strfolderdestnPath)
End If
fnFileInvalidExtn=strTestFileName_extn_chg
End Function
'File Rename
Public Function fnFileRename(strfolderSourcePath,strfolderdestnPath,strFile)
Set FSO=CreateObject("Scripting.FileSystemObject")
strfolderSourcePath_mod=strfolderSourcePath&"\"&strFile
strTestFileNamemsg=Split (strFile,".")
strTestFileNameFir=strTestFileNamemsg(0)
strNewTestFileName=Left(strTestFileNameFir,5)&"_"&"Data"& "_" & year(Date) & Right("00" & Month(Date),2) & Right("00" & Day(Date),2) & Right("00" & Hour(Time),2) & Right("00" & Minute(Time),2) & Right("00" & Second(Time),2) & ".dat"
strfolderdestnPath_mod=strfolderdestnPath&"\"&strNewTestFileName
FileEx=FSO.FileExists(strfolderSourcePath_mod)
If FileEx=True Then
FSO.MoveFile strfolderSourcePath_mod,strfolderdestnPath_mod
Call fnDoneResult("File Rename is Sucessful","File is renamed to " & strfolderdestnPath)
else
Call fnFailResult("File Rename is UnSucessful ","Unable to renamed file to " & strfolderdestnPath)
End If
fnFileRename=strNewTestFileName
End Function
'Function to modify the file data
Public Function fnModifyFile(strFilePath,strOrignalString, strmodifiedString)
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFilePath, ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, strOrignalString, strmodifiedString)
Set objFile = objFSO.OpenTextFile(strFilePath, ForWriting)
objFile.WriteLine strNewText
objFile.Close
End Function
Public Function fnFileInvalidExtn(strfolderSourcePath,strfolderdestnPath,strFile)
Set FSO=CreateObject("Scripting.FileSystemObject")
strfolderSourcePath_mod=strfolderSourcePath&"\"&strFile
strTestFileName1=Split (strFile,".")
strTestFileNameFir=strTestFileName1(0)
strTestFileName_extn_chg=strTestFileNameFir&"."&"d"
strfolderdestnPath_mod=strfolderdestnPath&"\"&strTestFileName_extn_chg
FileEx=FSO.FileExists(strfolderSourcePath_mod)
If FileEx=True Then
FSO.MoveFile strfolderSourcePath_mod,strfolderdestnPath_mod
Call fnDoneResult("File Extension changed is Sucessful","File is renamed to " & strfolderdestnPath)
else
Call fnFailResult("File Extension changed is UnSucessful ","Unable to renamed file to " & strfolderdestnPath)
End If
fnFileInvalidExtn=strTestFileName_extn_chg
End Function
'File Rename
Public Function fnFileRename(strfolderSourcePath,strfolderdestnPath,strFile)
Set FSO=CreateObject("Scripting.FileSystemObject")
strfolderSourcePath_mod=strfolderSourcePath&"\"&strFile
strTestFileNamemsg=Split (strFile,".")
strTestFileNameFir=strTestFileNamemsg(0)
strNewTestFileName=Left(strTestFileNameFir,5)&"_"&"Data"& "_" & year(Date) & Right("00" & Month(Date),2) & Right("00" & Day(Date),2) & Right("00" & Hour(Time),2) & Right("00" & Minute(Time),2) & Right("00" & Second(Time),2) & ".dat"
strfolderdestnPath_mod=strfolderdestnPath&"\"&strNewTestFileName
FileEx=FSO.FileExists(strfolderSourcePath_mod)
If FileEx=True Then
FSO.MoveFile strfolderSourcePath_mod,strfolderdestnPath_mod
Call fnDoneResult("File Rename is Sucessful","File is renamed to " & strfolderdestnPath)
else
Call fnFailResult("File Rename is UnSucessful ","Unable to renamed file to " & strfolderdestnPath)
End If
fnFileRename=strNewTestFileName
End Function
'Function to modify the file data
Public Function fnModifyFile(strFilePath,strOrignalString, strmodifiedString)
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFilePath, ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, strOrignalString, strmodifiedString)
Set objFile = objFSO.OpenTextFile(strFilePath, ForWriting)
objFile.WriteLine strNewText
objFile.Close
End Function
No comments:
Post a Comment