![]() |
jpg file name change
I have 12,000 jpg images that are associated with 12,000 part numbers.
The name of the image file does not match the part number. I am trying to change the name of the image to that of the part number. Other than individually renaming each jpg is there a way to do this |
jpg file name change
Sub ChangeImageFileNamesUsingListOnWorksheet()
'Jim Cone - San Francisco, USA - October 2006 'Renames files listed in Column A 'with the corresponding name in Column B. Dim objFSO As Object Dim objFolder As Object Dim objFile As Object Dim strPath As String Dim strName As String Dim varPos As Variant Dim rngList As Excel.Range 'Specify the folder... strPath = "C:\Documents and Settings\My Documents\Part Number Images" 'Specify where the file names are listed. Set rngList = ActiveSheet.Range("A1:A12000") 'Startup the file system object. Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strPath) For Each objFile In objFolder.Files strName = objFile.Name 'Find the file name in Column A. varPos = Application.Match(strName, rngList, 0) If Not IsError(varPos) Then 'Rename the file with the name in Column B. objFile.Name = rngList(varPos, 2).Value End If Next 'objFile Set objFile = Nothing Set objFolder = Nothing Set objFile = Nothing Set objFSO = Nothing End Sub '------------- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "dick" wrote in message I have 12,000 jpg images that are associated with 12,000 part numbers. The name of the image file does not match the part number. I am trying to change the name of the image to that of the part number. Other than individually renaming each jpg is there a way to do this |
jpg file name change
Thank you Jim
Jim Cone wrote: Sub ChangeImageFileNamesUsingListOnWorksheet() 'Jim Cone - San Francisco, USA - October 2006 'Renames files listed in Column A 'with the corresponding name in Column B. Dim objFSO As Object Dim objFolder As Object Dim objFile As Object Dim strPath As String Dim strName As String Dim varPos As Variant Dim rngList As Excel.Range 'Specify the folder... strPath = "C:\Documents and Settings\My Documents\Part Number Images" 'Specify where the file names are listed. Set rngList = ActiveSheet.Range("A1:A12000") 'Startup the file system object. Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strPath) For Each objFile In objFolder.Files strName = objFile.Name 'Find the file name in Column A. varPos = Application.Match(strName, rngList, 0) If Not IsError(varPos) Then 'Rename the file with the name in Column B. objFile.Name = rngList(varPos, 2).Value End If Next 'objFile Set objFile = Nothing Set objFolder = Nothing Set objFile = Nothing Set objFSO = Nothing End Sub '------------- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "dick" wrote in message I have 12,000 jpg images that are associated with 12,000 part numbers. The name of the image file does not match the part number. I am trying to change the name of the image to that of the part number. Other than individually renaming each jpg is there a way to do this |
All times are GMT +1. The time now is 11:53 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com