ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   rename unknown named files (https://www.excelbanter.com/excel-programming/382718-rename-unknown-named-files.html)

[email protected]

rename unknown named files
 
I have a bunch of different macros that are working at the moment the
only problem is that they will only work for a certain named file.

what I think would be the easiest way to make this work is to rename
the files in the folders.
these are the two folders which have the files I need to rename
C:\Documents and Settings\Owner\My Documents\Work\P123\dat
C:\Documents and Settings\Owner\My Documents\Work\P123\txt

Each folder would have 10 files in them at a time.


I would like to name them 1-10 dat and 1-10 txt if possible.

Any ideas???


Tom Ogilvy

rename unknown named files
 
Sub RenameFiles()
s1 = "C:\Documents and Settings\Owner\My Documents\Work\P123\dat\"
s2 = "C:\Documents and Settings\Owner\My Documents\Work\P123\txt\"
sName = dir(s1 & "*.*")
i = 0
do while sName < ""
i = i + 1
name s1 & sname as s1 & i & ".dat"
sName = dir()
Loop

sName = dir(s2 & "*.*")
i = 0
do while sName < ""
i = i + 1
name s2 & sname as s2 & i & ".txt"
sName = dir()
Loop

End Sub

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
I have a bunch of different macros that are working at the moment the
only problem is that they will only work for a certain named file.

what I think would be the easiest way to make this work is to rename
the files in the folders.
these are the two folders which have the files I need to rename
C:\Documents and Settings\Owner\My Documents\Work\P123\dat
C:\Documents and Settings\Owner\My Documents\Work\P123\txt

Each folder would have 10 files in them at a time.


I would like to name them 1-10 dat and 1-10 txt if possible.

Any ideas???




[email protected]

rename unknown named files
 
Amazing!!!!!!!!!!!
Thank you sooooo very much
Now what would I need to change if I wanted to use the same thing to
20,30 or more files?


Tom Ogilvy

rename unknown named files
 
nothing as long as they are named in numerical sequence from 1 to N

--
Regards,
Tom Ogilvy


wrote in message
ups.com...
Amazing!!!!!!!!!!!
Thank you sooooo very much
Now what would I need to change if I wanted to use the same thing to
20,30 or more files?





All times are GMT +1. The time now is 01:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com