?
Solved

Rename a directory that contains a file

Posted on 2014-10-08
6
Medium Priority
?
115 Views
Last Modified: 2014-10-08
Rename a directory that contains a file
old directory
C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\Bryant 4587 lotta way\flooring bids\Bids.dat
I am trying to remove replace this directory name, but copy the values of Bids.dat to the new directory

New name
C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\Bryant 4587 lotta way\Floor Repair bids\Bids.dat
how to do this?
0
Comment
Question by:isnoend2001
[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
  • 3
  • 2
6 Comments
 
LVL 12

Expert Comment

by:jkaios
ID: 40369554
There are several ways to do it.  If you're using the VB6, then the quickiest and simplies way to do it is to use the intrinsic function/statement.

Private Sub Form_Click()
   Name "C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\Bryant 4587 lotta way\flooring bids" As _
               "C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\Bryant 4587 lotta way\Floor Repair bids"
End Sub

Open in new window

0
 
LVL 15

Expert Comment

by:ChloesDad
ID: 40369574
If you just want to rename one folder to another then use the name command

     Name strSource As strTarget     (As jKaios stated, he beat me to it :))

where strsource is the original folder name and strtarget is the new folder name (that must not exist) if it already exists then it must be deleted first.

If you just want to move a file then the folder path in the strTarget must exist.
0
 

Author Comment

by:isnoend2001
ID: 40369612
thanks have already tried that eg:
Dim OldFileName As String
Dim NewFileName As String


OldFileName = "C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\Bryant 4587 lotta way\flooring bids\Bids.dat"
NewFileName = "C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\Bryant 4587 lotta way\Floor Repair bids\Bids.dat"
Name OldFileName As NewFileName 'error file not found
I want to keep the value of Bids.dat
I think the file under the last folder causes the problem
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 12

Accepted Solution

by:
jkaios earned 2000 total points
ID: 40369621
Since you're trying to rename just the DIRECTORY and NOT the FILE, you shouldn't include the filename.  Try the following (note that the "Bids.dat" file is NOT included in the strings).

OldFileName = "C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\Bryant 4587 lotta way\flooring bids"
NewFileName = "C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\Bryant 4587 lotta way\Floor Repair bids"

Name OldFileName As NewFileName

Open in new window

0
 

Author Closing Comment

by:isnoend2001
ID: 40369679
Thanks jkaios that is better than what i was thinking i would have to resort to:
copy the file
kill the file
remove the directory
save the file and new directory
0
 
LVL 12

Expert Comment

by:jkaios
ID: 40369713
Always a pleasure.  Very glad to be of assistance, especially to hear that it worked :-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month8 days, 6 hours left to enroll

764 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