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-06-25 08:27
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Challenge 1] Extract the last name in the directory [Difficulty: ☆] View 3,761 Replies 31
Floor 31 Posted 2008-04-08 09:08 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
Good post, learned something, up!
批处理之家新域名:www.bathome.net
Floor 32 Posted 2008-04-08 10:13 ·  中国 北京 联通
中级用户
★★
替身
Credits 269
Posts 130
Joined 2007-03-23 21:41
19-year member
UID 82683
Gender Female
Status Offline
If we say simply extracting the last segment of a path, I think the following code is sufficient


@echo off&setlocal
set "aaa=c:\windows\system32\playuo\cndos\asd adf"
for %%? in ("%aaa:\=" "%") do set cc=%%~?
echo.%cc%
Forum Jump: