set fs = CreateObject("Scripting.FileSystemObject")
this is needed to do some things with Files and Folders
set dateihandle = fs.GetFile("Backup Digicam.vbs")
with this we can get the path from the scriptfile to get the path where the Pictures should be taken
Set WshShell = CreateObject("WScript.Shell")
this is needed to execute dos commands and to end the scrip
b = Date & "_" & Time
this variable is the foldername for the pictures
b = replace(b,":",".")
because : isn't allowed in a path but behind a driveletter we need to get rid of the : from the time
c = dateihandle.Path
with this the scriptpath is copied to the variable c
c = left(c,len(c) - len("Backup Digicam.vbs") -1)
now we need to remove the filename from the variable
d = c & "" & b
now we merge the scriptpath with the new date and time based foldername
for x = 0 to 25
now we start checking every drive for the most used Digicam-Foldername: DCIM
y = chr(asc("A") + x) & „:“
to get from letter to letter we take the ASCII Code from A and add 0 up to 25 to get to Z, chr() makes a letter from the ASCII Code
If (fs.FolderExists(y & "DCIM")) Then
check for the foldername
select case msgbox("Autodetected Digicam = " & Y,3)
ask the user if the driveletter is the one from the digicam
case 6:
in case of 'Yes' proceed
a = y
exit for
exit the for-next loop
case 7:
in case of 'No' try longer
case 2: a = "":exit for
in case of 'Abort' exit
end select
end if
next
when the script lands here, it proceeds to the next number
if a = "" then msgbox "No Digicam found. Program is shutting down":WScript.Quit
if all letters where checked and no folder found, notify the user and exit
if right(a,1) <> ":" then
if a is not empty and has a letter but no : add a :
if len(a) = 1 then a = a & ":"
end if
fs.createfolder d
create the folder for the pictures
Wshshell.run "xcopy /s " & a & " """ & d & """"
start the copy progress
/s for subfolders