Solved Using dir or for command to show onl

May 25, 2014 at 13:13:59
Specs: Windows 64
Hi, is there a method in batch that I can use to output to a .txt file just the filenames in a folder on one side and the date the file was modified on the other side without the filesize and time it was modified on appearing?Thanks.

message edited by ssnader


See More: Using dir or for command to show onl

Report •


#1
May 25, 2014 at 18:19:31
✔ Best Answer
(for %%a in (*.*) do @echo %%~ta %%~nxa)>filelist

If you want the fullpath, use %%~dpnxa or %%~pnxa for the second item.

message edited by nbrane


Report •

#2
May 30, 2014 at 08:01:04
That's exactly what I needed, Thankyou. One follow up question:
1) How can I alter the command to include all files in subfolders as well and 2) Would there be a way to output everything in a particular order like making the name and date of the most recently modified file appear on the first line similar to how it can be done by using dir /tw, dir /od etc.


message edited by ssnader


Report •

#3
May 30, 2014 at 19:12:40
I'm not sure I understand, but sorted in date order into outputfile 'xx':
@echo off
(for /f "tokens=*" %%z in ('dir /b /s *.*') do (
@echo off
set x=%%~tz %%z
for /f "tokens=1-6* delims=/ " %%a in ("!x!") do echo %%c/%%a/%%b %%d %%e %%f
)
) | sort /r > xx
::---------- end batch
The batch got confused with echos and parentheses, got wierd outputs, hence the need for the extra junk.

Report •
Related Solutions


Ask Question