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-13 03:58
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » How to use the for + del command to delete files with spaces in the path View 3,914 Replies 15
Original Poster Posted 2006-05-31 19:36 ·  中国 四川 自贡 电信
新手上路
Credits 12
Posts 2
Joined 2006-05-28 00:13
20-year member
UID 56120
Status Offline
When running the command `for /r "C:\Documents and Settings\enc\My Documents" %%1 in (*.log *.tmp) do del %%1`, an error occurs: The system cannot find the specified path. In addition, files with spaces in the file name cannot be deleted either (clever XP recognizes it as n parts). why
Floor 2 Posted 2006-05-31 20:18 ·  中国 广东 佛山 电信
金牌会员
★★★★
Credits 3,467
Posts 1,616
Joined 2004-06-21 00:00
22-year member
UID 27148
Status Offline
%1 refers to the short file name, and the long file name is "%l". Using quotes solves the problem of file names with spaces.

In addition, a single percent sign is used in ordinary commands, while two percent signs are used in batch processing.
Floor 3 Posted 2006-06-04 16:26 ·  中国 福建 泉州 电信
高级用户
★★
论坛灌水专业户
Credits 613
Posts 266
Joined 2006-04-19 22:47
20-year member
UID 54113
From 河南省
Status Offline
What the person above said seems to be not very useful
饮马恒河畔,剑指天山西,碎叶城揽月,库叶岛赏雪,黑海之滨垂钓,贝尔加湖面张弓;中南半岛访古,东京废墟祭祖!
Floor 4 Posted 2006-06-04 16:44 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 247
Posts 83
Joined 2005-09-12 12:06
20-year member
UID 42446
Gender Male
Status Offline
I also have a similar problem, and it didn't succeed when operating temporary files with for!
Floor 5 Posted 2006-06-04 22:20 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 6 Posted 2006-06-04 22:43 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
In the non-command line input:
for /r "C:\Documents and Settings\enc\My Documents" %1 in (*.log *.tmp) do del "%1"
In the batch file input:
for /r "C:\Documents and Settings\fff\My Documents" %%1 in (*.log *.tmp) do del “%%1”
Floor 7 Posted 2006-06-05 11:09 ·  中国 上海 联通
金牌会员
★★★★
Credits 3,467
Posts 1,616
Joined 2004-06-21 00:00
22-year member
UID 27148
Status Offline
Note that in the second floor it's l (lowercase letter), not 1 (digit).
Floor 8 Posted 2006-06-05 11:15 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Originally posted by fujianabc at 2006-6-5 11:09:
Note what the second floor wrote, it's l (lowercase letter) not 1 (digit).

It's all the same, if you don't believe it, you can try it!
Floor 9 Posted 2006-06-05 20:53 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 247
Posts 83
Joined 2005-09-12 12:06
20-year member
UID 42446
Gender Male
Status Offline
6th floor is correct!
Another question:
I want to find a certain file among the searched files instead of performing a delete operation!
For example, search for files larger than 20kb in the C:\Documents and Settings\Administrator\Local Settings\Temporary Internet Files\ directory, or files of a specific time!
Floor 10 Posted 2006-06-06 08:53 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
You can try this upstairs to judge the file size
@echo off
setlocal enabledelayedexpansion
set a=
for /r "C:\Documents and Settings\Administrator\Local Settings\Temporary Internet Files" %%i in (*.*) do if %%~zi GTR 20480 set a=%%i !a!
echo The files larger than 20K are %a%

And for time, only the modification time of the file can be obtained
Floor 11 Posted 2006-06-09 09:35 ·  中国 福建 莆田 联通
中级用户
★★
DOS爱好者
Credits 213
Posts 99
Joined 2006-03-26 12:36
20-year member
UID 52807
Gender Male
Status Offline
I just learned today that there is still this command. I only knew the two delete commands Rd and del before
Floor 12 Posted 2006-06-09 21:13 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 247
Posts 83
Joined 2005-09-12 12:06
20-year member
UID 42446
Gender Male
Status Offline
Floor 13 Posted 2007-09-14 09:53 ·  中国 上海 电信
初级用户
Credits 40
Posts 17
Joined 2007-08-10 14:49
19-year member
UID 94928
Gender Male
Status Offline
How to display hidden files at the same time?
Floor 14 Posted 2007-09-14 10:22 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 471
Posts 207
Joined 2007-05-03 14:53
19-year member
UID 87369
Gender Male
Status Offline
For /R cannot traverse hidden files.
Floor 15 Posted 2007-10-04 15:40 ·  中国 浙江 温州 电信
初级用户
★★
Credits 158
Posts 89
Joined 2007-04-25 08:06
19-year member
UID 86402
Gender Male
Status Offline
Okay, learned it!!!
Forum Jump: