?
Solved

Moving Files with * Wildcard

Posted on 2003-03-17
8
Medium Priority
?
252 Views
Last Modified: 2010-05-01
I am trying to move all files of a cretain type from a directory I specify to another different directory. The idea is like the following from the command line:

move C:\*.text C:\temp\

How can I achieve this with VB6 as simply as possible?

Thanks-
Mack1er
0
Comment
Question by:mack1er
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 1

Accepted Solution

by:
JH0401 earned 280 total points
ID: 8154828
Dim NewFile

Do
New_File = Dir("C:\*.txt")
if new_file = "" then
   exit do
else
   filecopy "C:\" & new_file, "C:\temp\" & new_file
   kill "C:\" & new_file
end if
loop
0
 
LVL 1

Expert Comment

by:JH0401
ID: 8154859
the above assumes "C:\temp" directory exists
0
 
LVL 1

Expert Comment

by:JH0401
ID: 8154905
Sorry --- I guess it would help to define
the same variable you will be using in the
code!!!!

Dim New_File$
Do
New_File = Dir("C:\*.txt")
if new_file = "" then
  exit do
else
  filecopy "C:\" & new_file, "C:\temp\" & new_file
  kill "C:\" & new_file
end if
loop
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:Hornet241
ID: 8154919
Try this

Dim fname
fname = dir("C:\*.text")
do while fname > ""
    Name "C:\" & fname as "C:\temp\" & fname
    fname = dir
loop

All Done
0
 

Expert Comment

by:OzWolf
ID: 8154954
Try the following:

Dim strFileName as String
Dim strOldFileName as String
Dim strNewFileName as String

strFileName = Dir("C:\*.txt")

While strFileName <> ""
   strNewFileName = "C:\Temp\" & strFileName
   strOldFileName = "C:\" & strFileName
   Name strOldFileName as strNewFileName
   strFileName = Dir()
Wend
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 8155892
This is simple:

Private Sub Command1_Click()
Shell "command.com /c move C:\*.text C:\temp\", vbNormalFocus
End Sub

you could replace vbNormalFocus with vbHide if you do not want to see the window.
0
 

Author Comment

by:mack1er
ID: 8158662
JH0401,

That worked like a charm. Thanks!

Mack1er
0
 

Author Comment

by:mack1er
ID: 8158671
Worked great - thanks for the quick response.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question