Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Renaming Non-Excel Files

I am trying to figure out if I can rename non-excel files with excel.
I have a sheet with my file names in column A

G:\New Folder\Blank DA 1594.FPK
G:\New Folder\DA 1594 Example.pdf

and in column B I have the new names that I want to change them to.

G:\New Folder\Blank DA 1594 27 July 06.FPK
G:\New Folder\DA 1594 27 July 06.pdf

If anyone can help I would greatly appreciate it!!!!
Thanks in advance.

Glenn

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Renaming Non-Excel Files

Sub MoveFile()
Dim fso
Dim file As String, sfol As String, dfol As String, destFile
file = "Test.txt" ' change to match the file name
destFile = "TestMe.txt"
sfol = "C:\" ' change to match the source folder path
dfol = "C:\" ' change to match the destination folder path
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(sfol & file) Then
MsgBox sfol & file & " does not exist!", vbExclamation, "Source
File Missing"
ElseIf Not fso.FileExists(dfol & file) Then
fso.MoveFile (sfol & file), dfol & destFile
Else
MsgBox dfol & file & " already exists!", vbExclamation,
"Destination File Exists"
End If
End Sub

HTH

Die_Another_Day
QTGlennM wrote:
I am trying to figure out if I can rename non-excel files with excel.
I have a sheet with my file names in column A

G:\New Folder\Blank DA 1594.FPK
G:\New Folder\DA 1594 Example.pdf

and in column B I have the new names that I want to change them to.

G:\New Folder\Blank DA 1594 27 July 06.FPK
G:\New Folder\DA 1594 27 July 06.pdf

If anyone can help I would greatly appreciate it!!!!
Thanks in advance.

Glenn


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Renaming Non-Excel Files

You can also use the VBA Name function

Name "C:\SourceFolder\Test.xls" As "C:\DestFolder\TestNew.xls"


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Die_Another_Day" wrote in message ups.com...
Sub MoveFile()
Dim fso
Dim file As String, sfol As String, dfol As String, destFile
file = "Test.txt" ' change to match the file name
destFile = "TestMe.txt"
sfol = "C:\" ' change to match the source folder path
dfol = "C:\" ' change to match the destination folder path
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(sfol & file) Then
MsgBox sfol & file & " does not exist!", vbExclamation, "Source
File Missing"
ElseIf Not fso.FileExists(dfol & file) Then
fso.MoveFile (sfol & file), dfol & destFile
Else
MsgBox dfol & file & " already exists!", vbExclamation,
"Destination File Exists"
End If
End Sub

HTH

Die_Another_Day
QTGlennM wrote:
I am trying to figure out if I can rename non-excel files with excel.
I have a sheet with my file names in column A

G:\New Folder\Blank DA 1594.FPK
G:\New Folder\DA 1594 Example.pdf

and in column B I have the new names that I want to change them to.

G:\New Folder\Blank DA 1594 27 July 06.FPK
G:\New Folder\DA 1594 27 July 06.pdf

If anyone can help I would greatly appreciate it!!!!
Thanks in advance.

Glenn




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Renaming Non-Excel Files

Many thanks for this! I have exactly the same issue, with a long list of file
names, including the path, in Column A of a spreadsheet, and the new names
and path in Column B.

Since I am a non-technical person, I do not know how to adapt this code for
my purposes.

In my case I have a folder called NameStuff with the Excel spreadsheet in it
that has the old and new names, called this NameFile. There are two sub
folders in the folder. The folder with the files with the old names (in
Column A of NameFile) is called EntriesAll; and a second, empty folder
called EntriesAllRandom. (I am renaming a list of files with random numbers
rather than a descriptive name; this is for masking entrant names for the
judges.)

How might I adapt the code for my instance?

Many, many thanks in advance!
Hank


"Die_Another_Day" wrote:

Sub MoveFile()
Dim fso
Dim file As String, sfol As String, dfol As String, destFile
file = "Test.txt" ' change to match the file name
destFile = "TestMe.txt"
sfol = "C:\" ' change to match the source folder path
dfol = "C:\" ' change to match the destination folder path
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(sfol & file) Then
MsgBox sfol & file & " does not exist!", vbExclamation, "Source
File Missing"
ElseIf Not fso.FileExists(dfol & file) Then
fso.MoveFile (sfol & file), dfol & destFile
Else
MsgBox dfol & file & " already exists!", vbExclamation,
"Destination File Exists"
End If
End Sub

HTH

Die_Another_Day
QTGlennM wrote:
I am trying to figure out if I can rename non-excel files with excel.
I have a sheet with my file names in column A

G:\New Folder\Blank DA 1594.FPK
G:\New Folder\DA 1594 Example.pdf

and in column B I have the new names that I want to change them to.

G:\New Folder\Blank DA 1594 27 July 06.FPK
G:\New Folder\DA 1594 27 July 06.pdf

If anyone can help I would greatly appreciate it!!!!
Thanks in advance.

Glenn



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Renaming Non-Excel Files

Hi - I'd received a reply from Ron, which I am posting for the record from
him:

This code will read the list of file names and paths from Column A and copy
them and save them to a destination folder with the names in Column B.

Many thanks again!!!!

Sub test2()
Dim cell As Range
For Each cell In Columns("A").SpecialCells(xlCellTypeConstants)

'we check if the file exist in Column A before we try to copy it
If Dir(cell.Value) < "" Then
FileCopy cell.Value, cell.Offset(0, 1).Value
End If

Next cell
End Sub


Best,
Hank




"Hankster" wrote:

Many thanks for this! I have exactly the same issue, with a long list of file
names, including the path, in Column A of a spreadsheet, and the new names
and path in Column B.

Since I am a non-technical person, I do not know how to adapt this code for
my purposes.

In my case I have a folder called NameStuff with the Excel spreadsheet in it
that has the old and new names, called this NameFile. There are two sub
folders in the folder. The folder with the files with the old names (in
Column A of NameFile) is called EntriesAll; and a second, empty folder
called EntriesAllRandom. (I am renaming a list of files with random numbers
rather than a descriptive name; this is for masking entrant names for the
judges.)

How might I adapt the code for my instance?

Many, many thanks in advance!
Hank


"Die_Another_Day" wrote:

Sub MoveFile()
Dim fso
Dim file As String, sfol As String, dfol As String, destFile
file = "Test.txt" ' change to match the file name
destFile = "TestMe.txt"
sfol = "C:\" ' change to match the source folder path
dfol = "C:\" ' change to match the destination folder path
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(sfol & file) Then
MsgBox sfol & file & " does not exist!", vbExclamation, "Source
File Missing"
ElseIf Not fso.FileExists(dfol & file) Then
fso.MoveFile (sfol & file), dfol & destFile
Else
MsgBox dfol & file & " already exists!", vbExclamation,
"Destination File Exists"
End If
End Sub

HTH

Die_Another_Day
QTGlennM wrote:
I am trying to figure out if I can rename non-excel files with excel.
I have a sheet with my file names in column A

G:\New Folder\Blank DA 1594.FPK
G:\New Folder\DA 1594 Example.pdf

and in column B I have the new names that I want to change them to.

G:\New Folder\Blank DA 1594 27 July 06.FPK
G:\New Folder\DA 1594 27 July 06.pdf

If anyone can help I would greatly appreciate it!!!!
Thanks in advance.

Glenn





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
Renaming excel files in a folder Rhett C[_2_] Excel Discussion (Misc queries) 1 January 29th 10 05:23 AM
Excel Renaming Files When Opening Using File Convertor William McCann Excel Discussion (Misc queries) 0 November 25th 09 03:41 PM
Renaming Files w/Excel Confused VB Person Excel Discussion (Misc queries) 4 March 21st 08 09:26 AM
Batch renaming of many worksheets in Excel files? Lumen S Excel Discussion (Misc queries) 2 August 17th 06 09:48 PM
need macro for renaming bunch of excel files neowok[_83_] Excel Programming 3 August 11th 05 06:44 PM


All times are GMT +1. The time now is 06:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"