Import pictures from your digital camera

title says it all

Postby dgemily on Tue Mar 29, 2005 11:35 am

here it's an example of the script modified to use xevent plugin:


' -------------------------------------------8<-------------------------------------------
' Script : copy_CF.vbs
Dim MyDate, MyFolderDate, FSO, WshShellWav
Dim FileSystemObject, CopyFrom, CopyTo, DelTempFolder
Dim fsoXAlarm, wshXAlarm, XalarmPath, XEventCmd
Set fsoXAlarm = CreateObject("Scripting.FileSystemObject")
Set wshXAlarm = WScript.CreateObject("WScript.Shell")
XalarmPath = "c:\Program Files\XLobbyFr\plugins\XEvent\XAlarmClock.ini"

' ----------8<----------
' Copy from disk k: (my CompactFlash Reader, from sub folder \Dcim) to my local disk 'photo' folder i:\myCanon
' CopyFrom="K:\Dcim\"
' CopyTo="c:\myCanon\"
CopyFrom = WScript.Arguments(0)
CopyTo = WScript.Arguments(1)


' ----------8<----------
' If you have a directory to delete after copy, set its name below :
' This directory is created by my Canon Camera after a copy, I want to delete it...
DelTempFolder= "CANONMSC"


' ----------8<----------
WavExeTool = "C:\Program Files\Xlobbyfr\Applications\CopyPhotos\PlayWav.exe"
WavAudioFile = "C:\Program Files\Xlobbyfr\Applications\CopyPhotos\Sound.wav"


' -------------------------------------------8<-------------------------------------------


' ----------8<----------
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShellWav = WScript.CreateObject("WScript.Shell")

' ----------8<----------
' Verify if "PlayWav.exe" & ".wav" files are in WavExeTool/WavAudioFile directories
If ( not FSO.FileExists(WavExeTool) ) Then
MsgBox "Le programme 'PlayWav.exe' DOIT ETRE dans le repertoire : " & WavExeTool & " !!!",48,"Script Cine_Horaires..."
Wscript.quit
End If
If ( not FSO.FileExists(WavAudioFile) ) Then
MsgBox "Le fichier de son (.wav) existe-t-il dans : " & WavAudioFile & " ???",48,"Script Cine_Horaires..."
Wscript.quit
End If


' ----------8<----------
' Verify If original folded exists :
CopyFrom = Replace(CopyFrom,"*.*","")
CopyFrom = Replace(CopyFrom,"*","")
If not FSO.FolderExists( CopyFrom ) Then
MsgBox "Je ne trouve pas le repertoire contenant les images : [ " & CopyFrom & " ]", 64,"Erreur !"
Wscript.quit
End If
CopyFrom = CopyFrom & "\*"


' ----------8<----------
' Verify If destination folded exists :
If not FSO.FolderExists( CopyTo ) Then
MsgBox "Je ne trouve pas le repertoire de destination : [ " & CopyTo & " ]", 64,"Erreur !"
Wscript.quit
End If




' ----------8<----------
' Create a folder with current day date, in the 'CopyTo' folder destination
' This section could be removed (from here)
MyDate = Date
MyfolderDate = DatePart("yyyy",MyDate)

If DatePart("m",MyDate) < 10 then
MyfolderDate = MyfolderDate & "0" & DatePart("m",MyDate)
Else
MyfolderDate = MyfolderDate & DatePart("m",MyDate)
End If

If DatePart("d",MyDate) < 10 then
MyfolderDate = MyfolderDate & "0" & DatePart("d",MyDate)
Else
MyfolderDate = MyfolderDate & DatePart("d",MyDate)
End If


CopyTo = CopyTo & MyFolderDate & "\"

' (to here)
' ----------8<----------


' ----------8<----------
' Copy method

' Create destination directory (with Date !)
If not FSO.FolderExists( CopyTo ) Then
FSO.CreateFolder( CopyTo )
End If


' Copy Start...
ReturnVal = WshShellWav.run (chr(34)&WavExeTool&chr(34)&" "&chr(34)&WavAudioFile&chr(34),0,TRUE)

' Perform the copy of all files from camera (or Compact Flash Reader) to your destination directory
FSO.CopyFolder CopyFrom, CopyTo


' Do you want to delete a specific directory (unwanted one) ?
If ( Len(DelTempFolder) <> 0 ) Then
DelTempFolder = CopyTo & "\" & DelTempFolder
If FSO.FolderExists( DelTempFolder ) Then
FSO.DeleteFolder( DelTempFolder )
End If
End If


' ----------8<----------
' Copy done !
ReturnVal = WshShellWav.run (chr(34)&WavExeTool&chr(34)&" "&chr(34)&WavAudioFile&chr(34),0,TRUE)

' Debug information popup window :
MsgBox "Vos photos sont sur le disque dans : [ " & CopyTo & " ]", 64,"Copie effectuee !"
' ----------8<----------
XEventCmd = "pictures:refresh"
WriteEvent(XEventCmd)
' ----------8<----------
Function WriteEvent(str)
Dim tf
Set tf = fsoXAlarm.OpenTextFile(XalarmPath, 8, True)
tf.WriteLine( "now|" & str )
tf.Close
End Function

' -------------------------------------------8<-------------------------------------------


This script will download your pictures then, when the download it’s done, it will execute the event “refresh” of the eventgroups “pictures” of my skin.
So the database pictures will be automatically refreshed when the import will be done.

Dge.
dgemily
 
Posts: 793
Joined: Thu May 13, 2004 6:24 am
Location: Paris, France

Postby edgley on Tue Mar 29, 2005 10:57 pm

I was using the script from the visual skin.
I changed the alarm.ini to a text file as I didnt have the ini file.
I have decided to go for the script above instead.

I now have cut and paste the above text into copyphotos.vbs
I have added the plugin xevents.
I then have linked to the vbs with a button on my skin.
I dont have any triggers in xevents

When I hit the button I get the following error message:

line 13
char 1
error Subscript out of range
code 800a0009

I have looked at the script, and the only thing I could see to try was to remove the two comment marks, so these lines became active (I also changed them for my system):

CopyFrom="K:\Dcim\100olymp\"
CopyTo="c:\myCanon\"

Thank you for your help in getting this working :)
edgley
 
Posts: 240
Joined: Wed Apr 21, 2004 4:44 pm
Location: london

Postby dgemily on Wed Mar 30, 2005 7:38 am

edgley wrote:I have looked at the script, and the only thing I could see to try was to remove the two comment marks, so these lines became active (I also changed them for my system):

CopyFrom="K:\Dcim\100olymp\"
CopyTo="c:\myCanon\"


you don't need to change these lines, you must write these parameters by command lines.

try with the following instructions :

download this : http://france.xlobby.com/forum/dgemily/CopyPhotos.zip

then edit CopyPhotos.vbs and modify these lines for your system:
Code: Select all
WavExeTool    = "C:\Program Files\Xlobbyfr\Applications\CopyPhotos\PlayWav.exe"
WavAudioFile  = "C:\Program Files\Xlobbyfr\Applications\CopyPhotos\Sound.wav"


then, add an event os execute file pointing to CopyPhotos.vbs
and in parameters something like this :
Code: Select all
"L:\DCIM" "C:\Program Files\Xlobbyfr\Images Photos\"

(=" repertory source" " repertory of destination")

I think that you don't have to add, in the path, the repertory "100olymp" so instead of "K:\Dcim\100olymp\" write "K:\DCIM\"

let me know if it's working..

later,
dgemily
 
Posts: 793
Joined: Thu May 13, 2004 6:24 am
Location: Paris, France

Postby edgley on Thu Mar 31, 2005 12:58 am

:D :D :D

Thanks for your help!!

It works.

I have one other question though.

When it copies them to the disk, it creates a folder based on date, but inside of that it creates one called 100olymp and saves them it that.

I tried adding to the varible code k:\dcim\100olymp with and with \
but that causes an error.

Is there a way of getting the files saved just inside the date directory please?

Thanks
edgley
 
Posts: 240
Joined: Wed Apr 21, 2004 4:44 pm
Location: london

Postby dgemily on Thu Mar 31, 2005 7:47 am

I think that the vbs fom dalanik does that.

or on the original script you can delete :
Code: Select all
' This section could be removed (from here)
MyDate = Date
MyfolderDate = DatePart("yyyy",MyDate)

If DatePart("m",MyDate) < 10 then
MyfolderDate = MyfolderDate & "0" & DatePart("m",MyDate)
Else
MyfolderDate = MyfolderDate & DatePart("m",MyDate)
End If

If DatePart("d",MyDate) < 10 then
MyfolderDate = MyfolderDate & "0" & DatePart("d",MyDate)
Else
MyfolderDate = MyfolderDate & DatePart("d",MyDate)
End If


CopyTo = CopyTo & MyFolderDate & "\"

' (to here)


the script will not create a date folder , only the "100olymp" folder then you should rename this folder.

or maybe, modify little bit the vbs but I'm not sure yet what we have to change in it.

later
dgemily
 
Posts: 793
Joined: Thu May 13, 2004 6:24 am
Location: Paris, France

Postby dalanik on Thu Mar 31, 2005 9:09 am

Here's the latest script from the visual skin. You have 2 supply 2 parameter, see the remarks at the begining of the script on usage:

' --------------------------------------------------------------------------------------
' *** Script : CopyPhotos.vbs *** adapted by Dalibor Lanik 2004
' --------------------------------------------------------------------------------------
' *** This script will copy all files (photos) from your camera or memory card to the
' *** destination folder for pictures, according to the DateCreated of the file being
' *** copied. It will create sub-folders with dates, i.e. 2004\01\20040113, etc.
' *** usage: CopyPhotos.vbs "source folder" "destination folder"
' *** usage example: CopyPhotos.vbs "G:\DCIM\100OLYMP\" "D:\My Documents\pic\photos\"
' --------------------------------------------------------------------------------------

Option Explicit

Dim MyDate, MyFolderDate, FSO, WshShellWav
Dim FileSystemObject, CopyFrom, CopyTo, CopyToTwo
Dim WavExeTool, WavAudioFile, ReturnVal
Dim oFiles, oFolder, wsh, oFile, MakeDir, SourceFile, DestFile, tf

' *** Copy from disk arg1 (CompactFlash card, from sub folder \Dcim) to local disk 'photo' folder
CopyFrom = WScript.Arguments(0)
CopyTo = WScript.Arguments(1)

WavExeTool = "C:\Program Files\Xlobby\app\PlayWav.exe"
WavAudioFile = "C:\Program Files\Xlobby\app\action-finish.wav"

Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShellWav = WScript.CreateObject("WScript.Shell")

' *** Verify if "PlayWav.exe" & ".wav" files are in WavExeTool/WavAudioFile directories
If ( not FSO.FileExists(WavExeTool) ) Then
WriteEvent("overlays:show pictures copy-err-setup")
Wscript.quit
End If
If ( not FSO.FileExists(WavAudioFile) ) Then
WriteEvent("overlays:show pictures copy-err-setup")
Wscript.quit
End If

' *** Verify If source folder exists :
CopyFrom = Replace(CopyFrom,"*.*","")
CopyFrom = Replace(CopyFrom,"*","")
If not FSO.FolderExists( CopyFrom ) Then
WriteEvent("overlays:show pictures copy-err-src")
Wscript.quit
End If

' *** Verify If destination folder exists :
If not FSO.FolderExists( CopyTo ) Then
WriteEvent("overlays:show pictures copy-err-dest")
Wscript.quit
End If

Set wsh = WScript.CreateObject("WScript.Shell")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder(wsh.ExpandEnvironmentStrings(CopyFrom))
Set oFiles = oFolder.Files

For Each oFile In oFiles
MyDate = oFile.DateCreated

' *** create folder in format YYYY

MyfolderDate = DatePart("yyyy",MyDate)
MakeDir = CopyTo & MyFolderDate & "\"

' *** Create destination directory according to file DateCreated
If not fso.FolderExists( MakeDir ) Then
fso.CreateFolder( MakeDir )
End If

CopyToTwo = MakeDir

' *** create folder in format MM

If DatePart("m",MyDate) < 10 then
MyfolderDate = "0" & DatePart("m",MyDate)
Else
MyfolderDate = DatePart("m",MyDate)
End If

MakeDir = CopyToTwo & MyFolderDate & "\"

' *** Create destination directory according to file DateCreated
If not fso.FolderExists( MakeDir ) Then
fso.CreateFolder( MakeDir )
End If

CopyToTwo = MakeDir

' *** create folder in format YYYYMMDD

MyfolderDate = DatePart("yyyy",MyDate)

If DatePart("m",MyDate) < 10 then
MyfolderDate = MyfolderDate & "0" & DatePart("m",MyDate)
Else
MyfolderDate = MyfolderDate & DatePart("m",MyDate)
End If

If DatePart("d",MyDate) < 10 then
MyfolderDate = MyfolderDate & "0" & DatePart("d",MyDate)
Else
MyfolderDate = MyfolderDate & DatePart("d",MyDate)
End If

MakeDir = CopyToTwo & MyFolderDate & "\"

' *** Create destination directory according to file DateCreated
If not fso.FolderExists( MakeDir ) Then
fso.CreateFolder( MakeDir )
End If

SourceFile = CopyFrom & oFile.Name
DestFile = CopyToTwo & MyFolderDate & "\\" & oFile.Name

oFile.copy DestFile
Next

ReturnVal = WshShellWav.run (chr(34)&WavExeTool&chr(34)&" "&chr(34)&WavAudioFile&chr(34),0,TRUE)

WriteEvent("overlays:show pictures copy-ok")

Wscript.quit

' --------------------------------------------------------------------------------------
' functions
' --------------------------------------------------------------------------------------

Function WriteEvent(str)
Dim tf

Set tf = fso.OpenTextFile("c:\Program Files\XLobby\plugins\XEvent\XAlarmClock.ini", 8, True)

tf.WriteLine( "now|" & str )

tf.Close
End Function

' --------------------------------------------------------------------------------------
' end
' --------------------------------------------------------------------------------------


There is separate script for deleting the files; supply it 1 param (what to delete) - see remarks in script:

' --------------------------------------------------------------------------------------
' *** Script : DeletePhotos.vbs *** adapted by Dalibor Lanik 2004
' --------------------------------------------------------------------------------------
' *** This script will Delete all files (photos) from your camera or memory card after
' *** the files have been copied. Pay attention not to delete something you don't want!
' *** usage: DeletePhotos.vbs "source folder"
' *** usage example: DeletePhotos.vbs "G:\DCIM\100OLYMP\"
' --------------------------------------------------------------------------------------

Option Explicit

Dim MyDate, MyFolderDate, FSO, WshShellWav
Dim FileSystemObject, CopyFrom
Dim WavExeTool, WavAudioFile, ReturnVal
Dim oFiles, oFolder, wsh, oFile, tf

' *** delete files from arg1 (CompactFlash card, from sub folder \Dcim)
CopyFrom = WScript.Arguments(0)

WavExeTool = "C:\Program Files\Xlobby\app\PlayWav.exe"
WavAudioFile = "C:\Program Files\Xlobby\app\action-finish.wav"

Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShellWav = WScript.CreateObject("WScript.Shell")

' *** Verify if "PlayWav.exe" & ".wav" files are in WavExeTool/WavAudioFile directories
If ( not FSO.FileExists(WavExeTool) ) Then
WriteEvent("overlays:show pictures copy-err-setup")
Wscript.quit
End If
If ( not FSO.FileExists(WavAudioFile) ) Then
WriteEvent("overlays:show pictures copy-err-setup")
Wscript.quit
End If

' *** Verify If source folder exists :
CopyFrom = Replace(CopyFrom,"*.*","")
CopyFrom = Replace(CopyFrom,"*","")
If not FSO.FolderExists( CopyFrom ) Then
WriteEvent("overlays:show pictures copy-err-src")
Wscript.quit
End If

Set wsh = WScript.CreateObject("WScript.Shell")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder(wsh.ExpandEnvironmentStrings(CopyFrom))
Set oFiles = oFolder.Files

For Each oFile In oFiles
oFile.delete
Next

ReturnVal = WshShellWav.run (chr(34)&WavExeTool&chr(34)&" "&chr(34)&WavAudioFile&chr(34),0,TRUE)

WriteEvent("overlays:show pictures del-ok")

Wscript.quit

' --------------------------------------------------------------------------------------
' functions
' --------------------------------------------------------------------------------------

Function WriteEvent(str)
Dim tf

Set tf = fso.OpenTextFile("c:\Program Files\XLobby\plugins\XEvent\XAlarmClock.ini", 8, True)

tf.WriteLine( "now|" & str )

tf.Close
End Function

' --------------------------------------------------------------------------------------
' end
' --------------------------------------------------------------------------------------
dalanik
 
Posts: 885
Joined: Mon Apr 19, 2004 12:35 pm
Location: Prague, Czech Republic

Previous