Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to change closed file name - Error: file not found | Excel Programming | |||
2 users open same file and both can edit/change the file | Excel Discussion (Misc queries) | |||
How do I change *.CSV excel file to column seperated file? | Excel Discussion (Misc queries) | |||
How to change a MS Word file to an Excel file | Excel Worksheet Functions | |||
How do I change file/open/"files of type" to default to "all file. | Excel Discussion (Misc queries) |