我编写了一个VBScript,根据特定文件夹路径的文件类型对文件进行分组(作为输入)。我试图处理一个场景,当文件夹路径为空时,脚本应该要求我们提及文件路径。但是,我无法处理它。
v_Path = InputBox("Enter the FileName Along With Path")
If IsEmpty(v_Path) Then
MsgBox("What's the File Path?")
Else
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(v_Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
v_FileName = v_Path&"\" & objFile.Name
v_FileExtensionName = v_Path & "\" & objFso.GetExtensionName(v_FileName)
If Not(objFso.FolderExists(v_FileExtensionName)) Then
objFso.CreateFolder(v_FileExtensionName)
objFso.MoveFile v_FileName, v_FileExtensionName & "\"
Else
objFso.MoveFile v_FileName, v_FileExtensionName & "\"
End If
Next
MsgBox("Files Grouped Based on File Type!!")
End If
Set objFso = Nothing
Set objFolder = Nothing
Set colFiles = Nothing
答案 0 :(得分:3)
IsEmpty在这里查看字符串并说v_Path是否已初始化。如果变量是对象引用,或者未声明,则isEmpty将返回true。在这种情况下,消息框返回一个空字符串或“”
尝试此更改,
If Isempty(v_Path) or v_Path = "" Then
或只是
If v_Path = "" Then