Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi-
I have a bunch of files that all begin with a date - 20051231. After the date is the rest of the filename and this part of the filename varies. What I want to do is REPLACE the 20051231 portion of every file in a specific folder with FINAL 2005. To be more specific....I have over 1,000 files that each start with the date and then go on with a different name for each file. Example: 20051231_FileA 20051231_FileB 20051231_FileC I would like to keep the "FileA" portion of every file....but replace the 20051231 with FINAL 2005. Any ideas? Any help is greatly appreciated!! TIA, Chris |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub RenameFiles()
Dim List() as String, cnt as Long Dim fname as String cnt = 0 fname = Dir("C:\MyFolder\20051231_*.xls") do cnt = cnt + 1 redim preserve list(1 to cnt) list(cnt) = "C:\Myfolder\" & fname fname = dir() Loop while fname < "" for i = 1 to cnt Name list(i) as Replace(list(i),"20051231","FINAL 2005") Next End Sub -- Regards, Tom Ogilvy wrote in message oups.com... Hi- I have a bunch of files that all begin with a date - 20051231. After the date is the rest of the filename and this part of the filename varies. What I want to do is REPLACE the 20051231 portion of every file in a specific folder with FINAL 2005. To be more specific....I have over 1,000 files that each start with the date and then go on with a different name for each file. Example: 20051231_FileA 20051231_FileB 20051231_FileC I would like to keep the "FileA" portion of every file....but replace the 20051231 with FINAL 2005. Any ideas? Any help is greatly appreciated!! TIA, Chris |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Tom.
Don - Make sure there is a fileeditreplace option available before replying to any posts... Chris |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
*** CAUTION: PERFORM TEST RUNS FIRST! ***
Working from the DOS Command Prompt (Start|Programs|Accessories|Command Prompt) navigate to the target directory. Enter "RENAME ????????*.* FINAL2005*.*" at the prompt, then hit Enter. Notice that there are 8 question marks, but FINAL2005 (without the space) is 9 characters. With your example filenames, the underscore will be replaced. ALSO, any files that have the same names following the underscore will NOT be renamed because there cannot be duplicate filenames. Create a mock directory, add dummy text files with the old filenames, then try this on them so as to get an understanding of how the DOS RENAME function works *** BEFORE *** the actual execution. -- Trent Argante [DC.J(n/a)] " wrote: Hi- I have a bunch of files that all begin with a date - 20051231. After the date is the rest of the filename and this part of the filename varies. What I want to do is REPLACE the 20051231 portion of every file in a specific folder with FINAL 2005. To be more specific....I have over 1,000 files that each start with the date and then go on with a different name for each file. Example: 20051231_FileA 20051231_FileB 20051231_FileC I would like to keep the "FileA" portion of every file....but replace the 20051231 with FINAL 2005. Any ideas? Any help is greatly appreciated!! TIA, Chris |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim Filename As String
Dim Path As String Path = "c:\MyFolder\" Filename = Dir(Path & "2005*.txt") Do While Filename < "" Name Path & Filename As Path & Replace(Filename, Left(Filename, 8), "FINAL 2005") Filename = Dir Loop " wrote: Hi- I have a bunch of files that all begin with a date - 20051231. After the date is the rest of the filename and this part of the filename varies. What I want to do is REPLACE the 20051231 portion of every file in a specific folder with FINAL 2005. To be more specific....I have over 1,000 files that each start with the date and then go on with a different name for each file. Example: 20051231_FileA 20051231_FileB 20051231_FileC I would like to keep the "FileA" portion of every file....but replace the 20051231 with FINAL 2005. Any ideas? Any help is greatly appreciated!! TIA, Chris |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
replace letters for numbers | Excel Discussion (Misc queries) | |||
Replace the column letters with my own heading | Charts and Charting in Excel | |||
Formula to replace invalid filename characters | Excel Worksheet Functions | |||
Set Location and Filename to replace GetOpenFilename | Excel Programming | |||
Looking for an easy way to replace letters with acutes | Excel Worksheet Functions |