Code:Option ExplicitDim strPathDim FSODim FLDDim filDim strOldNameDim strNewNameDim strFilePartsDim intAccountDim intAccountAddstrPath = 'C:Scripts'intAccount = 000intAccountAdd = 001Set FSO = CreateObject('Scripting.FileSystemObject')Set FLD = FSO.GetFolder(strPath)For Each fil in FLD.FilesstrOldName = fil.PathintAccount = intAccount + intAccountAddIf InStr(strOldName, ') 0 ThenstrFileParts = Split(strOldName, ')strNewName = strFileParts(0) & intAccount & '.txt'FSO.MoveFile strOldName, strNewNameEnd IfNextSet FLD = NothingSet FSO = Nothing. Code: Option ExplicitDim strPathDim FSODim FLDDim filDim strOldNameDim strNewNameDim strFileParts'Define the path to the filestrPath = 'C:Documents and SettingsMarkDesktopRename Sample'Create the instance of the FSOSet FSO = CreateObject('Scripting.FileSystemObject')'Set the folder you want to search. Basically I have a folder with about 300 files that follow the naming convention: I would like to do is remove any part of the file name that has nofn which would leave me with: trying the script below which I thought would keep the 10 leftmost characters but it isnt working. Im a sysadmin just learning vbscript and Im having trouble with a rename script.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |