Seperate dir name and file name from 1%

  • Thread starter Thread starter Ricky
  • Start date Start date
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!
 
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.
 
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.
 
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.
 
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.
 
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!!
 
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
 
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
 
Back
Top