Link to home
Start Free TrialLog in
Avatar of coolguy2009
coolguy2009

asked on

image help needed

Hi,

I have a image files in directory"c:/images"

The file names are 1.jpg,2.jpg,atc.jpg etc...

I need a way to rename all the files inside the folder to thumb_1.jpg,thumb_2.jpg,thumb_atc.jpg etc...

Any help...
Avatar of FirstDownMage
FirstDownMage
Flag of United States of America image

There was another question here on EE that was answering this exact same problem.  Check it out here:
https://www.experts-exchange.com/questions/24142878/How-To-Rename-Multiple-Files.html
Avatar of coolguy2009
coolguy2009

ASKER

Hi,

That is the one he want to remove the words...But i need to append a word thumb_

That is not a solution i am expected..
Can anyone help me on this?

Try this

Ritesh
Sub renall()
Dim sPath, sFile, mFile, oFile As String
sPath = "D:\desktop\ee\"
sFile = Dir(sPath & "*.jpg")
 
Do While sFile <> ""
    oFile = sPath & sFile
    nfile = sPath & "thumb_" & sFile
    Name oFile As nfile
    sFile = Dir
Loop
End Sub

Open in new window

Please change sPath, Serach Path to your directory

Ritesh
I tried this nothing happens...

I saved this code in excel by alt f11 amd then i run alt f8...

Where i went wrong?What i did is correct?

Please advice...
Sub renall()
Dim sPath, sFile, mFile, oFile As String
sPath = "G:\thumb_images"
sFile = Dir(sPath & "*.jpg")
 
Do While sFile <> ""
    oFile = sPath & sFile
    nfile = sPath & "thumb_" & sFile
    Name oFile As nfile
    sFile = Dir
Loop
End Sub

Open in new window

Hi,

Here is my files and folder info...
ee-rename.JPG
I also change ur code?This also not renamed my files...
Sub renall()
Dim sPath, sFile, mFile, oFile As String
sPath = "G:\thumb_images"
sFile = Dir(sPath & "*.jpg")
 
Do While sFile <> ""
    oFile = sPath & sFile
    mFile = sPath & "thumb_" & sFile
    Name oFile As mFile
    sFile = Dir
Loop
End Sub

Open in new window

G:\thumb_images
Just put a back slash at hte end of it
G:\thumb_images\
and retry

Ritesh
I tried this..

File not found...
Sub renall()
Dim sPath, sFile, mFile, oFile As String
sPath = "G:\thumb_images\"
sFile = Dir(sPath & "*.jpg")
 
Do While sFile <> ""
    oFile = sPath & sFile
    mFile = sPath & "thumb_" & sFile
    Name oFile As mFile
    sFile = Dir
Loop
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of riteshparakh
riteshparakh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oops - please ignore my last comment - someone has already trapped that error.

Patrick