У меня есть базовый код vbs для разбиения имени файла на первом знаке подчеркивания. Например: t_e_s_t становится t. Я не хочу разделить имя файла, я хочу удалить аннотацию имени файла , которая будет состоять из "." «_» и пробелы.Сценарий vbs для удаления аннотации
Пожалуйста, может кто-нибудь просто взглянуть на код и рассказать мне, как его изменить?
Option Explicit
Dim strPath
Dim FSO
Dim FLD
Dim fil
Dim strOldName
Dim strNewName
Dim strFileParts
'Define the path to the file
strPath = inputbox("File path:")
'Create the instance of the FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
'Set the folder you want to search. NOTE - some antivirus may not like this
Set FLD = FSO.GetFolder(strPath)
'Loop through each file in the folder
For Each fil in FLD.Files
'Get complete file name with path
strOldName = fil.Path
'Check the file has an underscore in the name
If InStr(strOldName, "_") > 0 Then
'Split the file on the underscore so we can get everything before it
strFileParts = Split(strOldName, "_")
'Build the new file name with everything before the
'first under score plus the extension
strNewName = strFileParts(0) & ".txt"
'Use the MoveFile method to rename the file
FSO.MoveFile strOldName, strNewName
End If
Next
'Cleanup the objects
Set FLD = Nothing
Set FSO = Nothing
Спасибо очень! Я ценю это, и с некоторой корректировкой это будет делать именно то, что я хочу! – user2709851