Reputation: 101
I have a following problem. I am connecting to a windows 12 usb flash drive through and 12 port hub. I am writing a script where user can just double click it and have all files from a specific folder downloaded to a created folder on desktop. To make it universal I make user to input his windows user name and windows partition letter. And then (at the moment) I am asking the user to type all 12 letters one by one of the drives which is quite crude. I wanted to make it so that user has only to input the first letter of the drive and then automatically generate letters for 11 remaining drives as this is always the case that the drives are mounted with proper order of letters depending on the first one.
As it can be seen in the code I tried to do it with conversion to ascii and than back to character but it doesn't work and I can't find anything else that I could understand or implement.
I hope that is clear enough and thanks in advance for help!
This is the code (when I try to do the ascii conversion):
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."
Upvotes: 1
Views: 115
Reputation: 38775
Use Asc()/Chr() to convert between numbers and characters. Make sure to 'stop at Z'. As in:
>> 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
>>
Upvotes: 1