Seperate dir name and file name from 1%

R

Ricky

Hi,

By using %1, I can get the user input, ex: the file name in full path.
While, is there any command that can seperate the dir name from file name,
or is there any command can just return the dir name from user input?

Thanks!
 
D

David Candy

What's a percent 1. It can be more than one thing and the answer is yes or no depending on what you are talking about.
 
D

David Candy

Seeing you asked in a command prompt group (as I don't pay any attention to group names) I'll guess.

Type call /?
This is where the syntax is listed (and also in the for command). You don't need to use the call command.

The more common %1 in windows command line it is not possible.
 
M

Mark V

In said:
Hi,

By using %1, I can get the user input, ex: the file name in full
path. While, is there any command that can seperate the dir name
from file name, or is there any command can just return the dir
name from user input?

Perhaps this is really a batch file question?
What OS?
Example of "%1" would be helpful.
Certain tilde forms are available to "parse" fully qualified paths.
Try for /? perhaps.
 
P

Phil Robyn [MVP]

Ricky said:
Hi,

By using %1, I can get the user input, ex: the file name in full path.
While, is there any command that can seperate the dir name from file name,
or is there any command can just return the dir name from user input?

Thanks!

echo/The directory path is %~dp1

Type 'FOR /?' (without the apostrophes) at the CMD prompt for the answer
to your question.
 
R

Ricky

I am sorry to not make this question clear.

It is a batch file question. 1% is a parameter from user input. What I
really want to do is when user input (1%) contains both dir name and file
name, how can I just pick up the file name.

Thanks for your great help, I have solved it!!
 
A

Al Dunbar [MS-MVP]

Ricky said:
I am sorry to not make this question clear.

No problem. I thought your intent was painfully obvious, given the newsgroup
you posted in.

/Al
 
J

Jerold Schulman

Hi,

By using %1, I can get the user input, ex: the file name in full path.
While, is there any command that can seperate the dir name from file name,
or is there any command can just return the dir name from user input?

Thanks!
See tip 494 in the 'Tips & Tricks' at http://www.jsiinc.com

set drvpath=%~DP1
set drive=%~D1
set path=%~P1
set file=%~NX1
set FQFN=%~F1


Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
 

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