|
-
August 3rd, 2009, 04:50 AM
#1
Renaming Pictures files by comparing a list
Hi people
I have around 1300 jpeg's that need to be renamed based on the value in an excel spreadsheet.
What I need to be able to do is parse each jpeg in a directory, compare the filename to a list of names in a column in the spreadsheet and if it exists, rename it with the corresponding value from the next column and then move to the next file and so on and so on.
I have the following code for opening the spreadsheet and reading the files but am not sure how to compare the spreadsheet values to the filenames and then rename them:
Code:
Imports System
Imports System.IO
Imports System.IO.File
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Open Excel file and read info
Dim cnStudents As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Logon\WORK\ben\Desktop\Names.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=0""")
Dim daStudents As New OleDb.OleDbDataAdapter("Select * from [Sheet1$]", cnStudents)
Dim dsStudents As New DataSet
daStudents.Fill(dsStudents)
'Read picture files from folder
Dim s As String
For Each s In System.IO.Directory.GetFiles("\\logon\shared\Penalty Points\Backup\")
' do comparing and renaming here ??
Next s
End Sub
End Class
Can anyone help me out??
Thanks in advance
Visual Basic 2005 ver. 8.0.50727.867
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|