Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Rename Files

I have a bunch of files that I get scanned and returned to me with generic
names. I need these files renamed according to the name of the client in
each file. What I do is go through each file, before they get scanned, and
type out the name of each client from each file. I also get a list (in text
form) of each scanned file inserted into the excel sheet for parity.

Is there a macro that will search for the scanned file in the appropriate
folder according to the list in excel and rename it to client name that I
want to change it to?

I know this is long winded but what i'm looking for a way to rename a ton of
files as easy and as quickly as possible.

Any help would be appreciated.

Niq


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Rename Files

Hi Niq,

Does something like this get you started?

Sub D()
Dim sName As String
Dim Arr As Variant
Dim sNewName As String

ChDir "c:\temp"

sName = Dir("c:\temp\*.txt")
Do While Len(sName) 0
Arr = Split(sName, ".")
If UBound(Arr) = 1 Then
sNewName = Arr(0) & "XXX.txt"
' Change this obviously!
On Error GoTo NameAlreadyExists
Name sName As sNewName
On Error GoTo 0
End If
RestartPoint:
sName = Dir()
Loop
Exit Sub

NameAlreadyExists:
MsgBox "Cannot rename '" & sName & "' as '" & sNewName & "' already
exists"
Resume RestartPoint
End Sub

Obviously change the filter on the initial Dir call and the renaming rules!

HTH

Peter Beach

"Dominique Feteau" wrote in message
...
I have a bunch of files that I get scanned and returned to me with generic
names. I need these files renamed according to the name of the client in
each file. What I do is go through each file, before they get scanned,

and
type out the name of each client from each file. I also get a list (in

text
form) of each scanned file inserted into the excel sheet for parity.

Is there a macro that will search for the scanned file in the appropriate
folder according to the list in excel and rename it to client name that I
want to change it to?

I know this is long winded but what i'm looking for a way to rename a ton

of
files as easy and as quickly as possible.

Any help would be appreciated.

Niq




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 do I rename files that are related. FinnSchH2 Excel Discussion (Misc queries) 2 August 31st 07 02:12 PM
Help to rename files Hilton Excel Worksheet Functions 7 July 7th 07 03:51 AM
Import and Rename Files rickey24[_7_] Excel Programming 1 July 7th 04 02:43 AM
Rename Files from Explorer BENNY Excel Programming 2 June 19th 04 07:22 PM
Rename Batch of Files in VBA Darren Hill[_2_] Excel Programming 10 December 4th 03 08:31 AM


All times are GMT +1. The time now is 01:41 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"