작업중인 vbscript에 문제가 있습니다. 스크립트의 이름을 변경 한 다음 일부 FTP 로그 파일을 한 폴더에서 다른 폴더로 이동합니다. 스크립트가 작동하지만 delete_junkfiles.log라는 파일이 있다는 것을 알았지 만이 파일의 이름을 바꾸거나 이동하지 않으려 고합니다. 원본 폴더에서 그대로 남아 있습니다.VBScript로 로그 파일 이름 바꾸기 및 이동 문제가 발생했습니다.
현재 스크립트의 이름을 바꾸고 모든 파일을 이동 중입니다. 가능하면 스크립트 파일의 이름이 바뀌 었음에도 불구하고이 스크립트는 파일을 찾을 수 없으므로 오류가 발생합니다.
vbscript 전문가가 알고있는 사실은 매우 쉽습니다. ,하지만 난 꽤 vbs에 새로운이야 그리고 난 그냥 delete_junkfiles.log 무시하고 그냥 혼자두고 떠날 방법을 알아낼 수 없습니다. 녀석이 도움을 줄 수 있다면 도움이 될 것입니다. 다음은 내 스크립트 ....
Dim WshShell, FileManagement, BrowseDialogBox, SelectedFolder, OldString, NewString, FullPath, TheFolder, FileList
Dim File, ThisFile, TheString, AlreadyRenamed, TempName, FlagName, Success, FindFlag, NewName, Dummy
Set WshShell = WScript.CreateObject("WScript.Shell")
Set FileManagement = WScript.CreateObject ("Scripting.FileSystemObject")
Set BrowseDialogBox = WScript.CreateObject("Shell.Application")
Set SelectedFolder = BrowseDialogBox.BrowseForFolder(0, "Select the folder containing the files you want to rename.", &H0001)
If InStr(1, TypeName(SelectedFolder), "Folder") = 0 Then
Wscript.Quit
Else
OldString = InputBox("Enter the characters in the filename that you want to replace","Rename Files")
If OldString = "" Then Wscript.Quit
NewString = InputBox("Enter the characters that you want to replace them with","Rename Files")
If NewString = "" Then Wscript.Quit
End If
FullPath = SelectedFolder.ParentFolder.ParseName(SelectedFolder.Title).Path
Set TheFolder = FileManagement.GetFolder(FullPath)
Set FileList = TheFolder.Files
Success = 0
ThisFile = File.Name
TheString = InStr(ThisFile, OldString)
AlreadyRenamed = InStr(ThisFile, "%")
If (TheString <> 0) AND (AlreadyRenamed = 0) Then
Success = 1
TempName = Replace(ThisFile, OldString, NewString)
FlagName = "%" + TempName
File.Name = FlagName
End If
Next
For Each File in FileList
ThisFile = File.Name
FindFlag = InStr(ThisFile, "%")
If FindFlag <> 0 Then
NewName = Replace(ThisFile, "%", "")
File.Name = NewName
End If
Next
'Move the files
For Each File in FileList
FileManagement.MoveFile "C:\Users\lislej\Desktop\test_move\*.log", "C:\Users\lislej\Desktop\test_move_to\"
Next
If Success = 1 Then
Dummy = WshShell.Popup ("Rename Files operation complete!",5,"Rename Files",64)
Else
Dummy = WshShell.Popup ("Rename Files operation failed! Please repeat the operation.",0,"Rename Files",16)
End If
Wscript.Quit
고맙습니다. @PatricK, 코드 복사 및 붙여 넣기시 for 루프의 일부를 생략했습니다 .... 도움을 주셔서 감사합니다.하지만 문제가 조금 더 나아질 필요가 있다고 생각합니다. –
내가 조금 더 나아지고있는 문제를 설명했다. 위의 @Oracle에 답하는 댓글의 일부이다. 다시 감사한다. –
@JohnLisle 어떤 생각을하고 나면 이름을 변경 한 후에'FileList'를 다시 읽어 들여야한다고 생각한다. 그리고 당신은'File.Move'를 호출 할 수 있어야합니다. – PatricK