Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying all photos to desktop when memory card is inserted

Status
Not open for further replies.

soteman

Technical User
Jul 4, 2009
3
Hi all,

I am trying to write a simple script so that when I insert a USB memory card reader I can run it to automatically copy all of the photos on the card, and paste them into a new folder on the desktop, preferably with a box coming up in which to type a suitable folder name. I am completely stumped so any help would be much appreciated.

Cheers

Soteman
 
Easiest to automate the RoboCopy utility which is included in Vista and Windows 7 or a free download from Microsoft for Windows XP. Put robocopy in a directory in the path statement such as C:\Windows\System32.

Code:
Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
[green]
'First locate the users desktop[/green]
strDsk = WshShell.SpecialFolders("Desktop")
[green]
'Now add our base photo location[/green]
photobase = "\photos\"
[green]
'Ask for a new folder to create[/green]
newFolder = InputBox("Enter name of new photo directory to create.","New directory name")
photopath = strDsk & photobase & newFolder
If Not objFSO.FolderExists(photopath) Then
	objFSO.CreateFolder(photopath) Then
End If
[green]
'Now we copy from the thumb drive/flash card: replace G: with the appropriate flash drive[/green]
Call WshShell.Run("cmd.exe /k robocopy G:\ " & photopath & "\ /E /ZB /COPY:DAT /XO")





I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Thanks a lot..with a tiny bit of tinkering (it didn't like a few of the spacings for some reason), I have managed to get it to run smoothly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top