Writing a batch file

2

2007-User

On Windows Xp environment, can I write a BAT file (under DOS) that can read
the name of a directory and them assign that name to a file in another or
the same directory? (filename.ext <= directory name)

Thanks in advance.
 
P

Pegasus \(MVP\)

2007-User said:
On Windows Xp environment, can I write a BAT file (under DOS) that can read
the name of a directory and them assign that name to a file in another or
the same directory? (filename.ext <= directory name)

Thanks in advance.

The short answer to your question is "Yes, you can".

I suspect you would like to know how it's done. It would
be best if you gave an actual example to avoid having to
guess.
 
P

Poprivet

2007-User said:
On Windows Xp environment, can I write a BAT file (under DOS) that
can read the name of a directory and them assign that name to a file
in another or the same directory? (filename.ext <= directory name)

Thanks in advance.

For the experts in XP batch files, try:
alt.msdos.batch.nt

Those guys not only can do everything, but usually are great about sharing
the needed code.
 
P

Paul Randall

2007-User said:
On Windows Xp environment, can I write a BAT file (under DOS) that can
read
the name of a directory and them assign that name to a file in another or
the same directory? (filename.ext <= directory name)

Thanks in advance.

Since VBScript is installed by default on most XP systems, why not use that?
It is easier to understand and debug.

For example, the following three lines can be copied & pasted to notepad and
saved to a file named CurFldr.vbs:
MsgBox "Started in folder " & vbCrLf & _
WScript.CreateObject("WScript.Shell").CurrentDirectory
MsgBox "Done - quitting"

Double click click the file to run the script.

-Paul Randall
 
2

2007-User

Wow thank you so much Paul I didn't know anything about that ,
could you please tell me how it is possible to convert below batch file to
VBSCRIPT?

@ECHO ON
MD NEW-PROJECT
CD NEW-PROJECT
xcopy /d C:\007-JO~1\*.* D:\Documents and Settings\AFDESKTOP.001\Desktop
MD 09-Origfiles
MD 01-Sketches
MD 02-Received_Emails
MD 02-Sent_Emails
MD 01-Pictures
MD 03-Layouts
CD 03-Layouts
MD Drawings
MD Calculations
CD..
cls
tree
exit

Thank you.
2007-User
 
P

Pegasus \(MVP\)

VBScript is far more powerful than batch files. On the other
hand, batch files are far simpler to write for everyday tasks
such as making a few folders or perfoming some simple copy
commands, if only because they use standard Command
Prompt commands.

What has happened to your original question? Change of scope?

The batch file you posted has a few problems - see below.

2007-User said:
Wow thank you so much Paul I didn't know anything about that ,
could you please tell me how it is possible to convert below batch file to
VBSCRIPT?

@ECHO ON
MD NEW-PROJECT
*** Much better to write it like so:
*** md "d:\documents and settings\User\New-Project"
*** Now you know exactly where the folder will be created.
CD NEW-PROJECT
*** Ditto:
*** cd /d "d:\documents and settings\User\New-Project"
xcopy /d C:\007-JO~1\*.* D:\Documents and Settings\AFDESKTOP.001\Desktop
*** This won't work - you have embedded spaces. Do this instead:
*** xcopy /d C:\007-JO~1 "D:\Documents and Settings\AFDESKTOP.001\Desktop\"
MD 09-Origfiles
*** As above - add drive & folder name!
MD 01-Sketches
MD 02-Received_Emails
MD 02-Sent_Emails
MD 01-Pictures
MD 03-Layouts
CD 03-Layouts
MD Drawings
MD Calculations
CD..
*** What is the point of this command? Get rid of it!
*** What is the point of this command? Get rid of it!
tree
exit
*** What is the point of this command? Get rid of it!
 
2

2007-User

Well, I got so excited and forgot about my original question! ... certainly
I'll try to learn about this vbscripts in the near future ... until then,
let me ask you about my first question,
I need to read a folder's name and then assign this name to a file (rename
an existing file with this name) without touching the extension of this
file.

by the way thank you so much for your answer about my batch file.
---------------------------------------------------------------------------------------------------------------------------
 
2

2007-User

Paul,

If you don't mind and is going to be easy for you please answer this
question as well,

I would like to have a file that can do this: when I execute it, ask me
about a name in a dialog box and then create a folder with that name?

I really appreciate all of your helps


=================================================
 
P

Pegasus \(MVP\)

I am still unclear about your original question. As I said before,
an actual example would go a long way towards clarifying it.

This batch file will prompt you for your name:
@echo off
set /p name=Please enter your name:
echo Hello %name%, please clarify your question.
 
2

2007-User

Thanks for your reply, can you please give me the equivalent VBscript of the
batch file that I have posted here?
if it is not that easy could show me a good reference so I can figure that
out by myself?

Thanks.
 
P

Pegasus \(MVP\)

Sorry, I can't, VB Scripting is not my area of expertise. Perhaps
Paul Randall will respond, or else you could post your question
in a scripting newsgroup.
 
2

2007-User

Thanks anyway.

Pegasus (MVP) said:
Sorry, I can't, VB Scripting is not my area of expertise. Perhaps
Paul Randall will respond, or else you could post your question
in a scripting newsgroup.
 
A

Ayush

[2007-User]s message :
Thanks for your reply, can you please give me the equivalent VBscript of the
batch file that I have posted here?


one line:
WScript.Echo "Hello " & InputBox("Please enter your name:","Enter name") & ", please
clarify your question."

Good Luck, Ayush.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top