中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-13 05:00
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS学习入门 & 精彩文章 (教学室) » How to use the for + del command to delete files with spaces in the path
Printable Version  3,917 / 15
Floor1 sqn Posted 2006-05-31 19:36
新手上路 Posts 2 Credits 12
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
Floor2 fujianabc Posted 2006-05-31 20:18
金牌会员 Posts 1,616 Credits 3,467
%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.
Floor3 chineselgs Posted 2006-06-04 16:26
高级用户 Posts 266 Credits 613 From 河南省
What the person above said seems to be not very useful
Floor4 ily2013 Posted 2006-06-04 16:44
中级用户 Posts 83 Credits 247
I also have a similar problem, and it didn't succeed when operating temporary files with for!
Floor5 不得不爱 Posted 2006-06-04 22:20
超级版主 Posts 2,044 Credits 5,310 From 四川南充
Floor6 不得不爱 Posted 2006-06-04 22:43
超级版主 Posts 2,044 Credits 5,310 From 四川南充
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”
Floor7 fujianabc Posted 2006-06-05 11:09
金牌会员 Posts 1,616 Credits 3,467
Note that in the second floor it's l (lowercase letter), not 1 (digit).
Floor8 不得不爱 Posted 2006-06-05 11:15
超级版主 Posts 2,044 Credits 5,310 From 四川南充
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!
Floor9 ily2013 Posted 2006-06-05 20:53
中级用户 Posts 83 Credits 247
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!
Floor10 bagpipe Posted 2006-06-06 08:53
银牌会员 Posts 425 Credits 1,144 From 北京
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
Floor11 gwlok Posted 2006-06-09 09:35
中级用户 Posts 99 Credits 213
I just learned today that there is still this command. I only knew the two delete commands Rd and del before
Floor12 ily2013 Posted 2006-06-09 21:13
中级用户 Posts 83 Credits 247
Floor13 lyaa Posted 2007-09-14 09:53
初级用户 Posts 17 Credits 40
How to display hidden files at the same time?
Floor14 ThinKing Posted 2007-09-14 10:22
中级用户 Posts 207 Credits 471
For /R cannot traverse hidden files.
Floor15 kgdetg1127 Posted 2007-10-04 15:40
初级用户 Posts 89 Credits 158
Okay, learned it!!!
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023