You haven't explained how you're going to know what to change the file name TO.

The macro I gave you will generate a list of files and place it in a sheet 
(sheet1)
in column "A".

you can then add a second column to the sheet and supply the new name.

You can then write a macro to go through your list of files.
I would save the original file name as something like fName
and the new file name as NewName
then, use the filesystem object (fso) to check to see if the file exists, then

then use the movefile method:

fso.movefile SourceDir & fName, SourceDir & NewName
 
Paul
-----------------------------------------
“Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can.” - John Wesley
-----------------------------------------




________________________________
From: karthikeyan sankaran <karthikeyansankar...@gmail.com>
To: excel-macros@googlegroups.com
Sent: Fri, July 27, 2012 9:58:23 AM
Subject: Re: $$Excel-Macros$$ file rename-macro help

How to rename the get file name through excel macro

On 27/07/2012, Paul Schreiner <schreiner_p...@att.net> wrote:
> How much help do you need?
> Do you know anything about VBA?
> Have you tried anything on your own?
>
> This macro will generate the list of .pdf files in C:\temp
> into a list.
>
> Sub Get_Files()
>     Dim SourceDir, R
>     Dim fso, Fldr, Files, File
>     Dim Sht
>
>     Set fso = CreateObject("Scripting.FileSystemObject")
>     Sht = "Sheet1"
>     Sheets(Sht).Range("A2:A100000").ClearContents
>     SourceDir = "C:\temp"
>     R = 1
>     If (fso.folderexists(SourceDir)) Then
>         Set Fldr = fso.getfolder(SourceDir)
>         Set Files = Fldr.Files
>         For Each File In Files
>             If (Right(File.Name, 3) = "pdf") Then
>             R = R + 1
>             Sheets(Sht).Cells(R, "A").Value = File.Name
>             End If
>         Next
>     End If
> End Sub
>
> do you need help creating a macro to rename the files?
>
> Paul
> -----------------------------------------
> “Do all the good you can,
> By all the means you can,
> In all the ways you can,
> In all the places you can,
> At all the times you can,
> To all the people you can,
> As long as ever you can.” - John Wesley
> -----------------------------------------
>
>
>
>
> ________________________________
> From: karthikeyan sankaran <karthikeyansankar...@gmail.com>
> To: excel-macros@googlegroups.com
> Sent: Fri, July 27, 2012 9:24:11 AM
> Subject: $$Excel-Macros$$ file rename-macro help
>
> Hi,
>
> I have a 500 files(.pdf/.xls/.txt) in one folder.How to get .pdf files
> name only in excel sheet and rename desired name what i entered in
> other column in excel sheet.
> ex: old name            desired name
>       A.pdf                  karthik.pdf
>
> can any help and resolve this problem.Thanks for advance.
>
> Thanks
> karthik
>
> --
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help,
> Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not
> get
> quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5)  Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
>
> NOTE  : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>------------------------------------------------------------------------------------------------------
>-
>
> To post to this group, send email to excel-macros@googlegroups.com
>
> To unsubscribe, send a blank email to
> excel-macros+unsubscr...@googlegroups.com
>
> --
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
> not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5)  Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE  : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>------------------------------------------------------------------------------------------------------
>-
> To post to this group, send email to excel-macros@googlegroups.com
>
> To unsubscribe, send a blank email to
> excel-macros+unsubscr...@googlegroups.com
>
>
>

-- 
-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 


NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------

To post to this group, send email to excel-macros@googlegroups.com

To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com

-- 
-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com


Reply via email to