Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change closed file name - Error: file not found PGM Excel Programming 5 April 18th 06 02:07 PM
2 users open same file and both can edit/change the file RANDY Excel Discussion (Misc queries) 1 January 24th 06 04:06 PM
How do I change *.CSV excel file to column seperated file? Pankaj Excel Discussion (Misc queries) 2 July 5th 05 07:35 PM
How to change a MS Word file to an Excel file Sameera Excel Worksheet Functions 1 June 28th 05 08:57 PM
How do I change file/open/"files of type" to default to "all file. How do I changefiles of type default Excel Discussion (Misc queries) 1 April 19th 05 10:45 PM


All times are GMT +1. The time now is 10:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"