根据特定格式文件夹和子批处理文件列表 [英] Batch List files in folder and subfolder according to specific format

查看:117
本文介绍了根据特定格式文件夹和子批处理文件列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题
是否有可能使该阅读目录及子目录和输出一个批处理文件,结果以特定格式转换成txt文件?

I am having an question Is it possible to make an batch file that read the dir and subdirs and output the results in an specific format into an .txt file?

我知道如何阅读目录包括子迪尔斯等。
但我不知道是我怎么可以用一个特定的格式到.txt文件。

I know how to read the dir including sub dirs etc. But what i dont know is how i can use an specific format to an .txt file.

例如,我有

c:\patch
c:\patch\subfolder
c:\patch\subfolder\subfolder

在这些文件夹中,我有一些文件
我需要的是输出将是这样的

In those folders i have some files What i need is that the output will be something like this

2014-05-17  03:16p             7155712 file.exe
2014-05-11  03:41p            19287692 subfolder\file1.res
2014-05-11  03:42p            35508951 subfolder\subsubfolder\file1.res

等。

通过亲切的问候,

托马斯·德弗里斯。

推荐答案

修改:小修改答复意见

以下两点已被修改


  • 从DD-MM-YYYY转换日期为YYYY-MM-DD。

  • 在输出格式一些小的调整。

@echo off
setlocal EnableDelayedExpansion

set "base=%CD%"
set "base=%base:*:=%\"

for /R %%a in (*.*) do (
   for /F "tokens=1-5 delims=/-. " %%b in ("%%~Ta") do set "dateTime=%%d-%%c-%%b  %%e%%f"
   set "size=                   %%~Za"
   set name=%%~PNXa
   echo !dateTime! !size:~-19! !name:%base%=!
)

这篇关于根据特定格式文件夹和子批处理文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆