Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Not too sure if this is the related forum.
I want to create a batch file that looks at file 1's name, copies tha and then looks at file 2's name and copies that and then it rename file 1 with file 2's name and vice versa. Any ideas? Can it be done with batch programming or does it have to b done in C++ or java or can it be done in vba? Kind Regards Ian Rippin -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Ian,
If your files are (say) C:\One.txt and C:\Two.txt, just use a temporary intermediate file, say C:|\Temp.txt, Sub SwitchFileNames() Name "C:\One.txt" As "C:\Temp.txt" Name "C:\Two.txt" As "C:\One.txt" Name "c:\Temp.txt" As "C:\Two.txt" End Sub --- Regards, Norman "ianripping " wrote in message ... Not too sure if this is the related forum. I want to create a batch file that looks at file 1's name, copies that and then looks at file 2's name and copies that and then it renames file 1 with file 2's name and vice versa. Any ideas? Can it be done with batch programming or does it have to be done in C++ or java or can it be done in vba? Kind Regards Ian Ripping --- Message posted from http://www.ExcelForum.com/ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
As a batch file:
ren %1 %1.temp ren %2 %1 ren %1.temp %2 then call it like: mybatch.bat file1.txt file2.txt -- Rob van Gelder - http://www.vangelder.co.nz/excel "ianripping " wrote in message ... Not too sure if this is the related forum. I want to create a batch file that looks at file 1's name, copies that and then looks at file 2's name and copies that and then it renames file 1 with file 2's name and vice versa. Any ideas? Can it be done with batch programming or does it have to be done in C++ or java or can it be done in vba? Kind Regards Ian Ripping --- Message posted from http://www.ExcelForum.com/ |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Morning Ian,
Here is a simple little VBScript that does it. Dim temp, myFile1, myFile2, oFSO Set oFSO = CreateObject("Scripting.FileSystemObject") With oFSO Set myFile1 = .GetFile("C:\myTest\Volker1.xls") myFile1.Copy ("C:\myTest\temp.xls") Set temp = .GetFile("C:\myTest\temp.xls") Set myFile2 = .GetFile("C:\myTest\Volker2.xls") myFile2.Copy ("C:\myTest\Volker1.xls") temp.Copy ("C:\myTest\Volker2.xls") temp.Delete End With Just put it in a text file, save it as Rename.vbs, and then you can run it simply by double-clicking the file. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "ianripping " wrote in message ... Not too sure if this is the related forum. I want to create a batch file that looks at file 1's name, copies that and then looks at file 2's name and copies that and then it renames file 1 with file 2's name and vice versa. Any ideas? Can it be done with batch programming or does it have to be done in C++ or java or can it be done in vba? Kind Regards Ian Ripping --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Renaming Pictures | Excel Discussion (Misc queries) | |||
VB file renaming. | Excel Worksheet Functions | |||
RENAMING cells | Excel Discussion (Misc queries) | |||
Workbook renaming! | Excel Programming | |||
Renaming within VBA | Excel Programming |