Rename multiple *.jpg Files from English to Other Language

buvanamali

New Member
Joined
Jul 27, 2014
Messages
42
Dear Experts

With the following code, I am able to change a single *.jpg file to non English Name and the following code works fine. But my requirement is to rename multiple files.
Also the renamed file doesn't bear the file extn *.jpg.
VBA Code:
Sub ChangeFileName(sFile, tFile)
    On Local Error GoTo errors
    Dim fs, f, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    fs.Movefile sFile, tFile
    Set f = Nothing
    Exit Sub
errors:
    MsgBox "File: " & sFile & vbCrLf & Err.Description
    Err.Clear
End Sub

Sub test()
    Const sDir = "C:\temp\"
    ChangeFileName sDir & Range("A1").Value, sDir & Range("B1").Value
End Sub

The above code was found in your forum only.

p.s. Cross posted here: Excel Image Viewer and Rename its File Name
Please help me.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Do you have a list with the names in Column A and the renamed name in Column B. If so, does this work for you?

VBA Code:
Sub test()
On Error Resume Next
Dim c As Range, fLoc As String
fLoc = "C:\temp\"
For Each c In Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
    Name fLoc & c As fLoc & c.Offset(, 1)
Next
End Sub
 
Upvote 0
Do you have a list with the names in Column A and the renamed name in Column B. If so, does this work for you?

VBA Code:
Sub test()
On Error Resume Next
Dim c As Range, fLoc As String
fLoc = "C:\temp\"
For Each c In Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
    Name fLoc & c As fLoc & c.Offset(, 1)
Next
End Sub
Dear Experts
I have a list with the names in B3:B and the renamed name in Column C.
I changed the code as below. However, it doesn't rename the files.
VBA Code:
Sub test()
On Error Resume Next
Dim c As Range, fLoc As String
fLoc = "C:\temp\"
For Each c In Range("B3:B" & Range("B" & Rows.Count).End(xlUp).Row)
    Name fLoc & c As fLoc & c.Offset(, 2)
Next
End Sub
Thanking you
 
Upvote 0
Why did you change the offset to 2? Column C is only 1 away from Column B.

VBA Code:
Sub test()
On Error Resume Next
Dim c As Range, fLoc As String
fLoc = "C:\temp\"
For Each c In Range("B3:B" & Range("B" & Rows.Count).End(xlUp).Row)
Name fLoc & c As fLoc & c.Offset(, 1)
Next
End Sub
 
Upvote 0
Why did you change the offset to 2? Column C is only 1 away from Column B.

VBA Code:
Sub test()
On Error Resume Next
Dim c As Range, fLoc As String
fLoc = "C:\temp\"
For Each c In Range("B3:B" & Range("B" & Rows.Count).End(xlUp).Row)
Name fLoc & c As fLoc & c.Offset(, 1)
Next
End Sub
Tried as advised but no change in file name.
Please.
 
Upvote 0
I did test this. Is C:\temp\ the correct directory? Do you have the complete file name in the cells including the extension?
 
Upvote 0
Book1
ABC
1
2
3a.txtab.txt
4b.txtcd.txt
5
6
Sheet1


with before and after running macro

1711249931019.png
 

Attachments

  • 1711249846739.png
    1711249846739.png
    21.2 KB · Views: 19
Upvote 0
I also tested it. From English to English it is quite Ok. Whereas I am trying to change it from English to Tamil Language. the mini sheet is enclosed.
Please help.
 

Attachments

  • Test.jpg
    Test.jpg
    204.5 KB · Views: 31
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top