China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-07 06:22
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » What does "~na" mean in for? View 1,679 Replies 9
Original Poster Posted 2007-04-14 12:36 ·  中国 河北 廊坊 联通
初级用户
Credits 108
Posts 35
Joined 2007-04-12 15:23
19-year member
UID 84897
Gender Male
From 河北廊坊
Status Offline
What does %~na mean in "for /r g:\mp3 %a in (*.mp3) do @echo %~na"?
In the for /? help:
%~I expands %I by removing any surrounding quotes ("").
%~fI expands %I to the fully qualified pathname.
%~dI expands %I to just the drive letter.
%~pI expands %I to just the path.
%~nI expands %I to just the file name.
%~xI expands %I to just the file extension.
%~sI expands the path to only contain the short name.
%~aI expands %I to the file attributes of the file.
%~tI expands %I to the date and time of the file.
%~zI expands %I to the file size.
Here it says "expands %I to the fully qualified pathname" and "expands %I to just the drive letter", what does this mean? I don't quite understand. Can you give an example to explain it?
Floor 2 Posted 2007-04-14 21:27 ·  中国 浙江 杭州 华数宽带
银牌会员
★★★
Credits 2,000
Posts 621
Joined 2007-01-01 00:00
19-year member
UID 75212
Gender Male
Status Offline
Isn't it written above?

Expand to the file name;

For example, there is a test.mp3 in g:\mp3

If you just echo %a, it will echo as g:\mp3\test.mp3

If you echo %~na, it will echo as test

Only the file name itself
Floor 3 Posted 2007-04-14 21:55 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 866
Posts 415
Joined 2005-12-04 11:19
20-year member
UID 46459
Status Offline
@echo off
:: Please place this batch file on the desktop and run it.
echo The fully qualified pathname of this batch file is: %~f0
echo The drive letter of this batch file is: %~d0
pause>nul
Floor 4 Posted 2007-04-14 23:13 ·  中国 河北 廊坊 联通
初级用户
Credits 108
Posts 35
Joined 2007-04-12 15:23
19-year member
UID 84897
Gender Male
From 河北廊坊
Status Offline
Thanks everyone, got it!
Been to so many forums, but this one is the best!
It has a human touch! Haha~!~!~!
Floor 5 Posted 2007-04-15 04:58 ·  中国 陕西 西安 电信
初级用户
★★
Credits 112
Posts 50
Joined 2007-04-15 00:59
19-year member
UID 85191
Gender Male
Status Offline
Learned a little more! Thanks!
Floor 6 Posted 2007-04-15 14:41 ·  中国 浙江 台州 临海市 电信
初级用户
Credits 48
Posts 26
Joined 2007-04-09 14:14
19-year member
UID 84505
Gender Male
Status Offline
Thanks for sharing, saved it
Floor 7 Posted 2007-04-21 09:54 ·  中国 广东 中山 电信
初级用户
★★
Credits 127
Posts 62
Joined 2007-04-19 12:43
19-year member
UID 85744
Gender Male
Status Offline
Thanks everyone, got it!
Floor 8 Posted 2007-04-22 00:00 ·  中国 广东 广州 白云区 电信
新手上路
Credits 2
Posts 1
Joined 2007-04-21 23:37
19-year member
UID 86016
Gender Male
Status Offline
Okay, support the fall
Floor 9 Posted 2008-01-05 17:13 ·  中国 广东 汕头 潮阳区 电信
高级用户
★★★
DOS时空
Credits 713
Posts 348
Joined 2007-02-10 13:59
19-year member
UID 79169
Gender Male
Status Offline
Easy to understand, plus points.
Floor 10 Posted 2008-01-07 19:41 ·  中国 福建 电信
初级用户
Credits 46
Posts 24
Joined 2008-01-04 22:09
18-year member
UID 107690
Gender Male
Status Offline
Thanks for sharing
Forum Jump: