dustin255
dustin255

Reputation: 31

How do I create a batch file that creates a list of files in a folder along with date last accessed and size?

How do I create a batch file that creates a list of files in a folder along with date last accessed and size?

My code is this so far:

dir /b /s > fileslist.txt

and creates a list of the contents in the folder the batch file is located like this:

C:\Users\UserOne\Documents\3D Designs
C:\Users\UserOne\Documents\Adobe
C:\Users\UserOne\Documents\AirDroid
C:\Users\UserOne\Documents\Amazon Downloader Logs
C:\Users\UserOne\Documents\AppScan
C:\Users\UserOne\Documents\Audacity

Upvotes: 2

Views: 1041

Answers (1)

user6250760
user6250760

Reputation:

This should be closer to what you want:

@echo off
for /f "skip=5 tokens=1-4*" %%A in ('dir /ta /s /a-d') do (
    if "%%A" NEQ "Directory" if "%%E" NEQ "" if "%%B" NEQ "Dir(s)" echo %%E ^|^| %%A %%B %%C %%D
)
pause

Output:

C:\fileName.ext || 2017/10/4 00:00 AM 42

The code does:

  • Gets a list of files and folders
  • Sort out necessaries strings
  • Output them with a proper format, either
    • C:\fileName.ext || [last accessed date time] [byte count]
    • C:\folderToTest || [last accessed date time]

Upvotes: 1

Related Questions