1

我有以下问题。我通过 12 端口集线器连接到 Windows 12 USB 闪存驱动器。我正在编写一个脚本,用户可以双击它并将特定文件夹中的所有文件下载到桌面上创建的文件夹中。为了使其通用,我让用户输入他的 windows 用户名和 windows 分区号。然后(目前)我要求用户一个一个地输入所有 12 个字母,这非常粗糙。我想让它让用户只需要输入驱动器的第一个字母,然后自动为剩余的 11 个驱动器生成字母,因为在这种情况下,驱动器总是以正确的字母顺序安装,具体取决于第一个驱动器。

从代码中可以看出,我尝试通过转换为 ascii 而不是返回字符来做到这一点,但它不起作用,我找不到任何其他我能理解或实现的东西。

我希望这足够清楚,并提前感谢您的帮助!

这是代码(当我尝试进行 ascii 转换时):

DIM fso
Set fso=CreateObject("Scripting.FilesystemObject")
On Error Resume Next   

Set oDrive = fso.Drives

username = InputBox("Enter winows user name")
wl = Inputbox("Enter Your windows partition drive letter")


l0 = Inputbox("Enter Your 1st camera drive letter")
'l1 = Inputbox("Enter Your 2nd camera drive letter")
'l2 = Inputbox("Enter Your 3rd camera drive letter")
'l3 = Inputbox("Enter Your 4th camera drive letter")
'l4 = Inputbox("Enter Your 5th camera drive letter")
'l5 = Inputbox("Enter Your 6th camera drive letter")
'l6 = Inputbox("Enter Your 7th camera drive letter")
'l7 = Inputbox("Enter Your 8th camera drive letter")
'l8 = Inputbox("Enter Your 9th camera drive letter")
'l9 = Inputbox("Enter Your 10th camera drive letter")
'l10 = Inputbox("Enter Your 11th camera drive letter")
'l11 = Inputbox("Enter Your 12th camera drive letter")


fso.CreateFolder ""& wl &":\Users\"& username &"\Desktop\recording"

fso.CreateFolder ""& wl &":\Users\"& username &"\Desktop\recording\cam0"
fso.CopyFile ""& l0 &":\DCIM\100HDDVR\*.*", ""& wl &":\Users\"& username &"\Desktop\recording\cam0\"

fso.CreateFolder ""& wl &":\Users\"& username &"\Desktop\recording\cam1"
'fso.CopyFile ""& l1 &":\DCIM\100HDDVR\*.*", ""& wl &":\Users\"& username &"\Desktop\recording\cam1\"
fso.CopyFile "Chr(Asc('"& l0 &"') + 1):\DCIM\100HDDVR\*.*", ""& wl &":\Users\"& username &"\Desktop\recording\cam1\"

fso.CreateFolder ""& wl &":\Users\"& username &"\Desktop\recording\cam2"
fso.CopyFile ""& l2 &":\DCIM\100HDDVR\*.*", ""& wl &":\Users\"& username &"\Desktop\recording\cam2\"

fso.CreateFolder ""& wl &":\Users\"& username &"\Desktop\recording\cam3"
fso.CopyFile ""& l3 &":\DCIM\100HDDVR\*.*", ""& wl &":\Users\"& username &"\Desktop\recording\cam3\"

fso.CreateFolder ""& wl &":\Users\"& username &"\Desktop\recording\cam4"
fso.CopyFile ""& l4 &":\DCIM\100HDDVR\*.*", ""& wl &":\Users\"& username &"\Desktop\recording\cam4\"

fso.CreateFolder ""& wl &":\Users\"& username &"\Desktop\recording\cam5"
fso.CopyFile ""& l5 &":\DCIM\100HDDVR\*.*", ""& wl &":\Users\"& username &"\Desktop\recording\cam5\"

fso.CreateFolder ""& wl &":\Users\"& username &"\Desktop\recording\cam6"
fso.CopyFile ""& l6 &":\DCIM\100HDDVR\*.*", ""& wl &":\Users\"& username &"\Desktop\recording\cam6\"

fso.CreateFolder ""& wl &":\Users\"& username &"\Desktop\recording\cam7"
fso.CopyFile ""& l7 &":\DCIM\100HDDVR\*.*", ""& wl &":\Users\"& username &"\Desktop\recording\cam7\"

fso.CreateFolder ""& wl &":\Users\"& username &"\Desktop\recording\cam8"
fso.CopyFile ""& l8 &":\DCIM\100HDDVR\*.*", ""& wl &":\Users\"& username &"\Desktop\recording\cam8\"

fso.CreateFolder ""& wl &":\Users\"& username &"\Desktop\recording\cam9"
fso.CopyFile ""& l9 &":\DCIM\100HDDVR\*.*", ""& wl &":\Users\"& username &"\Desktop\recording\cam9\"

fso.CreateFolder ""& wl &":\Users\"& username &"\Desktop\recording\cam10"
fso.CopyFile ""& l10 &":\DCIM\100HDDVR\*.*", ""& wl &":\Users\"& username &"\Desktop\recording\cam10\"

fso.CreateFolder ""& wl &":\Users\"& username &"\Desktop\recording\cam11"
fso.CopyFile ""& l11 &":\DCIM\100HDDVR\*.*", ""& wl &":\Users\"& username &"\Desktop\recording\cam11\"


Wscript.Echo "File copy complete."
4

1 回答 1

1

使用Asc() / Chr()在数字和字符之间进行转换。确保“停在 Z”。如:

>> Function min(a, b) : If a <= b Then : min = a : Else : min = b : End If : End Function
>> For Each d In Split("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z")
>>     a = Asc(d)
>>     WScript.Stdout.Write d & " " & a & ":"
>>     For i = a To min(Asc("Z"), a + 11)
>>         WScript.Stdout.Write " " & Chr(i)
>>     Next
>>     WScript.Stdout.WriteLine
>> Next
>>
A 65: A B C D E F G H I J K L
B 66: B C D E F G H I J K L M
C 67: C D E F G H I J K L M N
D 68: D E F G H I J K L M N O
E 69: E F G H I J K L M N O P
F 70: F G H I J K L M N O P Q
G 71: G H I J K L M N O P Q R
H 72: H I J K L M N O P Q R S
I 73: I J K L M N O P Q R S T
J 74: J K L M N O P Q R S T U
K 75: K L M N O P Q R S T U V
L 76: L M N O P Q R S T U V W
M 77: M N O P Q R S T U V W X
N 78: N O P Q R S T U V W X Y
O 79: O P Q R S T U V W X Y Z
P 80: P Q R S T U V W X Y Z
Q 81: Q R S T U V W X Y Z
R 82: R S T U V W X Y Z
S 83: S T U V W X Y Z
T 84: T U V W X Y Z
U 85: U V W X Y Z
V 86: V W X Y Z
W 87: W X Y Z
X 88: X Y Z
Y 89: Y Z
Z 90: Z
>>
于 2016-08-10T18:00:31.460 回答