我不知道这是否是正确的问题,但我正在学习。我有一个网页上有一些按钮 喜欢日本,东京,印度,英国,美国
以及包含图像的文件夹
YK08HJX_SYPTE_20140403170541594.jpg
YK08HJX_SYPTE_20140403170542194.jpg
1YK0BHJX_SYPTE1-PC_20140403170000670.jpg
。当用户点击网页上的任何按钮时,它应该将sypte1-PC或SYPTE更改为该按钮文本。
YK08HJX_japan_20140403170541594.jpg
YK08HJX_INDIA_20140403170542194.jpg
1YK0BHJX_UK_20140403170000670.jpg.
任何帮助将不胜感激。
这是我的代码:但是如何在按钮点击或href上直接与网页进行交互。文本。
清单A:RenameFiles.vbs
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
For Each File In FileList
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
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
答案 0 :(得分:0)
您提到您无法与网页或按钮点击进行互动。所以我会帮助你完成这一部分。您可以创建单击按钮单击事件,只要单击任何按钮就会触发该事件。这样您就可以将代码保存在一个子目录中。这是一个例子:
<html>
<body>
<script language="vbscript">
Sub DoClick(strText)
' strText will hold the name of the button that was clicked.
' Use it to rename your files.
End Sub
</script>
<input type="button" onclick="DoClick('Japan')" value="Japan" />
<input type="button" onclick="DoClick('USA')" value="USA" />
</body>
</html>