Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default The existing filenames are too long.

Hi,

Is it possible to rename all the files in a folder with the first twelve
characters of the existing filename?

Ta,

DL


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default The existing filenames are too long.

Here is a sub that will rename a file. In this case it is actually moving it
on your HD.
Sub movefile()
OldName = "C:\personal\1065.xls"
NewName = "C:\a\1065.xls"
Name OldName As NewName
End Sub

So, this should do what you want. Change Myfolder to suit. Test as is then
change the ' comment lines

Sub RenameFiles()
Application.ScreenUpdating = False
Dim FN As String ' For File Name
Dim MyFolder As String
MyFolder = "c:\a\*.xls"
FN = Dir(MyFolder)
Do Until FN = ""
If FN < "PERSONAL.XLS" Then
MsgBox """" & Left(MyFolder, Len(MyFolder) - 5) & FN & """"
'oldname="""" & Left(MyFolder, Len(MyFolder) - 5) & FN & """"
MsgBox """" & Left(MyFolder, Len(MyFolder) - 5) & Left(FN, 12) & ".xls"""
'newname="""" & Left(MyFolder, Len(MyFolder) - 5) & left(fn,12) & ".xls"""
'Name OldName As NewName
End If
FN = Dir
Loop
Application.ScreenUpdating = True
End Sub


--
Don Guillett
SalesAid Software

"fitful_thought" wrote in message
...
Hi,

Is it possible to rename all the files in a folder with the first twelve
characters of the existing filename?

Ta,

DL




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
http://CannotDeleteFile.net - Cannot Delete File? Try Long Path ToolFilename is too long? Computer Complaining Your Filename Is Too Long? TheLong Path Tool Can Help While most people can go about their businessblissfully unaware of the Windo Max Loger Excel Discussion (Misc queries) 0 June 14th 11 04:30 PM
Long Long Long Nested If Function sed Excel Discussion (Misc queries) 4 December 9th 09 06:44 PM
can not scroll on Edit links very long list of filenames Louw Rademeyer SARS Excel Discussion (Misc queries) 1 March 19th 09 12:48 PM
Clearing cells takes long, long time unclemuffin Excel Discussion (Misc queries) 9 August 17th 07 02:22 AM
download existing spreadsheets into another existing spreadsheet lbierer Excel Discussion (Misc queries) 2 September 24th 06 08:36 PM


All times are GMT +1. The time now is 09:04 PM.

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"