标题: 搜索D盘*.txt后再按文件名顺序(怎样忽略文件夹顺序呀)
[打印本页]
作者: yywd
时间: 2008-6-19 18:19
标题: 搜索D盘*.txt后再按文件名顺序(怎样忽略文件夹顺序呀)
搜索D盘*.txt后再按文件名顺序(怎样忽略文件夹顺序呀)
搜索*.txt后再按文件名顺序(忽略文件夹顺序)排序写入完整路径到1.txt
怎样忽略文件夹顺序呀
例如D盘有
D:\b.txt
D:\d.txt
D:\1\c.txt
D:\1\f.txt
D:\2\1\a.txt
D:\2\1\g.txt
D:\2\1\1\e.txt
则1.txt如下
D:\2\1\a.txt
D:\b.txt
D:\1\c.txt
D:\d.txt
D:\2\1\1\e.txt
D:\1\f.txt
D:\2\1\g.txt
作者: pusofalse
时间: 2008-6-19 18:26
试下这个。。。
dir d:\*.txt /b/s/a-d/on
作者: yywd
时间: 2008-6-19 18:29
Quote: |
Originally posted by pusofalse at 2008-6-19 18:26:
试下这个。。。
dir d:\*.txt /b/s/a-d/on |
|
没有忽略文件夹顺序呀
怎样忽略文件夹顺序呀
作者: pusofalse
时间: 2008-6-19 18:35
for %%a in (a b c d e f g) do dir d:\%%a.txt /b/s/a-d
无比低慢的代码,不过应该会满足你的要求。。
作者: yywd
时间: 2008-6-19 18:50
Quote: |
Originally posted by pusofalse at 2008-6-19 18:35:
for %%a in (a b c d e f g) do dir d:\%%a.txt /b/s/a-d
无比低慢的代码,不过应该会满足你的要求。。 |
|
好像不行, D盘的txt文件名也并不确定
作者: pusofalse
时间: 2008-6-19 18:57
你确定子目录下不会有重名的文件吗~?而且文件名全是字母?
作者: yywd
时间: 2008-6-19 19:05
Quote: |
Originally posted by pusofalse at 2008-6-19 18:57:
你确定下不会有重名的文件吗~?而且文件名全是字母? |
|
子目录不确定有重名的文件,而且文件名不全是字母,可能是中文+字母+数字甚至符号呀
作者: pusofalse
时间: 2008-6-19 19:05
@echo off&setlocal enabledelayedexpansion
for /r d:\ %%a in (*.txt) do set "%%~na=%%a"
for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do if defined %%a echo !%%a!
pause>nul
作者: pusofalse
时间: 2008-6-19 19:12
Quote: |
Originally posted by yywd at 2008-6-19 07:05 PM:
子目录不确定有重名的文件,而且文件名不全是字母,可能是中文+字母+数字甚至符号呀 |
|
Oh my god....
那你想要输出时,字母在最前面?然后数字,再后中文。。。
还是中文最前,数字最后?~
中文实在是不好考虑。。。。
作者: yywd
时间: 2008-6-19 19:42
Quote: |
Originally posted by pusofalse at 2008-6-19 19:12:
Oh my god....
那你想要输出时,字母在最前面?然后数字,再后中文。。。
还是中文最前,数字最后?~
中文实在是不好考虑。。。。 |
|
输出时数字在最前面,然后字母,再后中文。。。
作者: pusofalse
时间: 2008-6-19 19:49
@echo off&setlocal enabledelayedexpansion
for /r d:\ %%a in (*.txt) do set "#%%~na=%%a"
for /f "tokens=2 delims==" %%a in ('set #') do echo %%a
pause>nul
输出类似于:
1
2
a
b
c
d
dp
dp23
dpa
DP
e
f
汉字
....
[
Last edited by pusofalse on 2008-6-19 at 07:53 PM ]
作者: balinger
时间: 2008-6-19 19:59
@echo off
if exist "%temp%\list.txt" del /f/a/q "%temp%\list.txt"
for /r d: %%i in (*.txt) do echo %%~ni\%%i>>"%temp%\list.txt"
for /f "tokens=1* delims=\" %%i in ('more %%temp%%\list.txt^|sort') do echo %%j>>list.txt
del /f/a/q "%temp%\list.txt"
pause
作者: yywd
时间: 2008-6-19 20:08
Quote: |
Originally posted by pusofalse at 2008-6-19 19:49:
@echo off&setlocal enabledelayedexpansion
for /r d:\ %%a in (*.txt) do set "#%%~na=%%a"
for /f "tokens=2 delims==" %%a in ('set #') do echo %%a
pause>nul
输出类似 ... |
|
谢谢您的热心帮助, 这个可以用的
作者: yywd
时间: 2008-6-19 20:11
Quote: |
Originally posted by balinger at 2008-6-19 19:59:
@echo off
if exist "%temp%\list.txt" del /f/a/q "%temp%\list.txt"
for /r d: %%i in (*.txt) do echo %%~ni\%%i>>"%temp%\list.txt"
for /f "tokens=1* delims= ... |
|
谢谢您的热心帮助,您 这个也可以用的
作者: PPdos
时间: 2008-6-19 20:51
小写了一行 不知是否楼住所要求的 只是将文件名 放在了路径前边 比较快
(for /r d:\ %i in (*.txt) do echo %~nxi %~si)|sort /o d:/cn-dos.txt
作者: WANKOILZ
时间: 2008-6-19 23:14
楼上的括号用得太经典了!!