473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Rename filenames

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
3 1156
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
* "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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: fanbanlo | last post by:
C:\MP3\001.txt -> 0.txt C:\MP3\01. ??? - ????(???).mp3 -> 1.mp3 Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in...
0
by: Bruce P. | last post by:
I have a C++ routine that uses the fcloseall() command, then moves immediately into a routine that renames the files just closed. Occasionally, a rename will fail, even though both the "from" and...
3
by: Venkat | last post by:
Hi All, Currently i guess rename and remove are not supported using fstream. How do i rename or remove a file? regards, Venkat
7
by: Tom | last post by:
I'm having a problem using a path with spaces as a parameter to os.rename() in a program on WinXP. This works fine at the command line (where the folder "c:\aa bb" exists) > os.rename( "c\aa...
0
by: Bruce P. | last post by:
I have a C routine that uses the fcloseall() command, then moves immediately into a routine that renames the files just closed. Occasionally, a rename will fail, even though both the "from" and...
9
by: rodchar | last post by:
hey all, i was just wondering if you name the web.config any name as long as it has the .config? True or False, why. thanks, rodchar
3
by: glub glub | last post by:
i'm trying to make a program that works as Replace works in MS Word but this is for use with files, not a text document. FolderBrowserDialog1.ShowDialog() txtPath.Text =...
8
by: Merlin | last post by:
Ok.... I feel really dumb on this one, because I had previously figured it out, and now don't have a clue. I'm trying to get the user to input a new filename (via an integer variable) and...
1
by: jonathan184 | last post by:
trying to rename filenames and extensions then add a header in line1 of each file if the header existed in line 1 to go to the next file. but i am getting error explciti errors Here is my...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.