473,625 Members | 3,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

rename and count files

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.

FolderBrowserDi alog1.ShowDialo g()
txtPath.Text = FolderBrowserDi alog1.SelectedP ath

above are the 2 lines of code i have so far, i would like to display/add the
files to a list view and i feel that i would have to count the amount of
files in the specified directory to do so, so how would i count the amount
of files and add them to the list view?

i have 2 text boxes for the find and replace and button to replace, how
would i find and rename the files in the "search"?

ex (i would like to be able to search for spaces in a file name and replace
those spaces with no spaces using this program)
Nov 20 '05 #1
3 6409
* "glub glub" <no**@none.co m> scripsit:
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.

FolderBrowserDi alog1.ShowDialo g()
txtPath.Text = FolderBrowserDi alog1.SelectedP ath

above are the 2 lines of code i have so far, i would like to display/add the
files to a list view and i feel that i would have to count the amount of
files in the specified directory to do so, so how would i count the amount
of files and add them to the list view?

i have 2 text boxes for the find and replace and button to replace, how
would i find and rename the files in the "search"?


'System.IO.Dire ctory.GetFiles' will return an array of filenames in a
certain directory.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #2
ok, how would i use that though? i was thinking i would have to use a loop
to add each file to the list view or is there another way?

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:bn******** *****@ID-208219.news.uni-berlin.de...
* "glub glub" <no**@none.co m> scripsit:
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.

FolderBrowserDi alog1.ShowDialo g()
txtPath.Text = FolderBrowserDi alog1.SelectedP ath

above are the 2 lines of code i have so far, i would like to display/add the files to a list view and i feel that i would have to count the amount of
files in the specified directory to do so, so how would i count the amount of files and add them to the list view?

i have 2 text boxes for the find and replace and button to replace, how
would i find and rename the files in the "search"?


'System.IO.Dire ctory.GetFiles' will return an array of filenames in a
certain directory.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>

Nov 20 '05 #3
* "glub glub" <no**@none.co m> scripsit:
ok, how would i use that though? i was thinking i would have to use a loop
to add each file to the list view or is there another way?


\\\
Dim s As String
For Each s In System.IO.Direc tory.GetFiles(" C:\WINDOWS")
Dim li As New ListViewItem()
li.Text = System.IO.Path. GetFileName(s)
li.Tag = s
Me.ListView1.It ems.Add(li)
Next s
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<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

16
2974
by: dudufigueiredo | last post by:
I have one folder containing mp3 files, the folder is: C:\My Shared Folder\Rubber Soul And the files are: 01 drive my car.mp3 02 norwegian wood.mp3 03 you won't see me.mp3 04 nowhere man.mp3 .. ..
3
1170
by: Newbie | last post by:
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.
5
4452
by: Rothariger | last post by:
Hello.... i want to know if its posible to rename multiple files like windows does.. example: file zzzzzzz.doc file asdasd.doc file esfsefse.doc
2
5831
by: AA Arens | last post by:
During my database construction, I left the names of the buttons, comboboxes named by default like Combo77, Command43. I can rename them with Properties Other Name, but them I start getting troubles with the VB. Is there any solution, or tool to have this renamed and autorenamed all values in VB? Bart Acc 2003
12
2889
by: mantrid | last post by:
Im trying to move a file but am having luck my code is below. The temp and target paths are valid as they echo correctly. but I cant get the copy() function to work, or the rename() function $target_path = $targetdir . basename($uploadedfile); $temp_path = $tempdir. basename($uploadedfile); echo "Target - ".$target_path." Temp - ".$temp_path."<br>";
1
4436
by: hardik | last post by:
can anyone tell me how i can change the filename which is going to uploaded here is a code for uploading a file <!-- #include file="clsUpload.asp" --> Set objUpload = New clsUpload If objUpload.Files.Count 0 Then objUpload.Files.Item(0).Save Server.MapPath("cupload\")
6
2527
by: shuaishuaiyes | last post by:
Hello everyone... I'm a Chinese student and my English is very poor...So excuse me if I make grammar mistake. I want to ask some questions about "rename". I'm a beginner, so my C ..... :) I want to rename a batch of files..Such as I want to rename"1.avi,2.avi" to "Prison BreakS1E1.avi,Prison BreakS1E2.avi" in the same folder..How can I do?
2
3622
by: =?iso-8859-1?b?cultaQ==?= | last post by:
Hi, I would like to rename files (jpg's ones) using a text file containing the new names... Below is the code that doesn't work : ***** #!/usr/bin/python #-*- coding: utf-8 -*- from os import listdir, getcwd, rename import re
1
5712
by: achotto | last post by:
hi, i try to upload a multiple image files. after that i will rename the files name. the problem is when i upload a 2 or more same files name exp-goal.jpg, it will return "files already exist". ok this is my codes, Set Upload = Server.CreateObject("Persits.Upload.1") Count = Upload.Save("d:\cmsupload\cimg\") for each File in upload.Files ' '...sme operation here..
0
8256
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8694
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8356
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6118
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4193
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.