By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,572 Members | 1,516 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,572 IT Pros & Developers. It's quick & easy.

Rename filenames

P: n/a
Hello,

I'm trying to rename 2000+ jpg files in a directory. all
filenames are similar, so that makes it a little bit
easier. They look like at123456a, at123457a, etc.

What I need to do is delete the "t" in the 2nd position
of each file. I can't seem to get my loop to work quite
right.

TIA
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
replace your destination filename with source.replace("t","")

"Newbie" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
Hello,

I'm trying to rename 2000+ jpg files in a directory. all
filenames are similar, so that makes it a little bit
easier. They look like at123456a, at123457a, etc.

What I need to do is delete the "t" in the 2nd position
of each file. I can't seem to get my loop to work quite
right.

TIA

Nov 20 '05 #2

P: n/a
* "Newbie" <an*******@discussions.microsoft.com> scripsit:
I'm trying to rename 2000+ jpg files in a directory. all
filenames are similar, so that makes it a little bit
easier. They look like at123456a, at123457a, etc.

What I need to do is delete the "t" in the 2nd position
of each file. I can't seem to get my loop to work quite
right.


'Microsoft.VisualBasic.Rename' or 'File.Move'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

P: n/a

Below is my code, but it isn't working.

Dim files As String
Dim i As Integer
Dim count As Integer

Me.FileListBox1.Path = "C:\jpgs\"
count = Me.FileListBox1.Items.Count
files = Me.FileListBox1.FileName

For i = 0 To count - 1
System.IO.File.Move(Me.FileListBox1.Items
(i).ToString, & Me.FileListBox1.Items(i).Replace("t", ""))

Next

End Sub

-----Original Message-----
* "Newbie" <an*******@discussions.microsoft.com>

scripsit:
I'm trying to rename 2000+ jpg files in a directory. all filenames are similar, so that makes it a little bit
easier. They look like at123456a, at123457a, etc.

What I need to do is delete the "t" in the 2nd position of each file. I can't seem to get my loop to work quite right.


'Microsoft.VisualBasic.Rename' or 'File.Move'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
.

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.