darg and drop: how to get short name of the parametre

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
budhax
Posts: 63
Joined: 09 Oct 2006 12:25

darg and drop: how to get short name of the parametre

#1 Post by budhax » 30 Oct 2006 16:10

Hello,
my BAT file test.bat contains:

Code: Select all

set p1=%1
echo %p1%
pause


and I get:

"C:\Documents and Settings\sam\Bureau\folderA"


if I drag the folder "folderA" located on the desktop (=Bureau in French) and drop it on the test.bat file.

My goal is to get only folderA, without the full path and without the double quotes.

Anyone could help me, please? Thank you.

budhax
Posts: 63
Joined: 09 Oct 2006 12:25

#2 Post by budhax » 30 Oct 2006 16:26

I mean, at least without the full path.

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#3 Post by DosItHelp » 30 Oct 2006 18:37

budhax,

To get the directory name only without quotes try:
set p1=%~n1

DOS IT HELP? :wink:

budhax
Posts: 63
Joined: 09 Oct 2006 12:25

#4 Post by budhax » 31 Oct 2006 05:13

Thanks a lot, it helps me :o

Post Reply