Forum Moderators: open

Message Too Old, No Replies

jpeg batch file processing (renaming)

         

humpingdan

8:58 am on Dec 3, 2004 (gmt 0)

10+ Year Member



ive got a load of pictures all in jpeg format, i need to import them into a school database which is for student records. The filenames much match the student ID, unfortunatly they are saved by UPN number, Unique - Pupil - Number - both these numbers are unique to each student.

i can run a report to pull out the "studentID" and the matching "UPN" but is there anyway to match that then with the filename and replace it with the StudentID>>>

some kind of patch processing?

mattur

2:52 pm on Dec 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you're using Windows you could write a simple WSH vbscript (.vbs) to query the database using ADO, loop through the results and use the FileSystemObject to rename each file. Something like:


[i]'open db connection[/i]
Set cnn = CreateObject("ADODB.Connection")
cnn.Open *your_db_connection_string*

[i]'query database[/i]
Set rst = cnn.Execute(*your_sql_query*)

[i]'get file system object[/i]
Set fso = CreateObject("Scripting.FileSystemObject")

[i]'loop thru recordset[/i]
Do While Not rst.EOF

[i]'rename image file[/i]
fso.MoveFile *your_file_path* & rst("UPN") & ".jpg", *your_file_path* & rst("SID") & ".jpg"
rst.MoveNext

Loop