Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Batch File To Copy Pictures

Posted on 2009-07-09
3
Medium Priority
?
1,546 Views
Last Modified: 2012-05-07
I am looking for a way to copy all of my digital camera pictures into a folder by using a batch file.  If it's possible, I would like the batch file to read the date that the picture was taken, and make that date the name of the folder.  Once the folder is created, I need the batch to copy all photos to the folder that corresponds to the date the picture was taken . Is this a fairly simple process? Can someone provide a sample of how I would do this, or point me in the right direction? Thanks.
0
Comment
Question by:thedeal56
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 38

Expert Comment

by:Shift-3
ID: 24814882
This is beyond the capabilities of batch scripting, but could probably be done with vbscript.  Like batch, vbscript runs natively without installing any additional software.  Would that be acceptable?

Also, I don't have a digital camera to test with, but when you connect yours does it show up in the Storage\Disk Management node in Computer Management?  Can you right-click it , hit Change Drive Letter and Paths, click Add, and mount it to an empty NTFS folder on your C: drive?

If so then moving the files from a mounted folder would be a lot easier than trying to grab them directly from the camera.
0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 2000 total points
ID: 24815485
Assuming all those things are true, paste the script below into a text file with a .vbs extension.  Customize the value of the strSource variable on line 1 with the location of the folder you mounted the camera to.  Customize the value of the strDest variable with the location of the folder to move the photos to.

Running the script will move all pictures from the camera to subfolders named for the dates they were taken.


strSource = "c:\camera mount point"
strDest = "c:\photos"
 
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")
 
For Each objItem in colItems
    If InStr(objItem.Caption, "Vista") Or InStr(objItem.Caption, "2008") Then
        intDetail = 12
    Else
        intDetail = 25
    End If
Next
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
If Not objFSO.FolderExists(strDest) Then
    objFSO.CreateFolder strDest
End If
 
Set objShell = CreateObject("Shell.Application")
Set objSource = objShell.Namespace(strSource)
 
For Each objFile in objSource.Items
    dtmTaken = objSource.GetDetailsOf(objFile, intDetail)
    
    If dtmTaken <> "" Then
        strNewFolder = strDest & "\" & ShortDate(dtmTaken)
        
        If Not objFSO.FolderExists(strNewFolder) Then
            objFSO.CreateFolder strNewFolder
        End If
 
        objFSO.MoveFile objFile.Path, strNewFolder & "\"
    End If
Next
 
Function ShortDate(dtmTime)
    strYear = Year(dtmTime)
    strMonth = Right("0" & Month(dtmTime), 2)
    strDay = Right("0" & Day(dtmTime), 2)
    
    ShortDate = strYear & strMonth & strDay
End Function

Open in new window

0
 

Author Comment

by:thedeal56
ID: 24816427
Wow, thank you very much.  That is very cool; it works great.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Loops Section Overview
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question