Batch to list the number of files in a folder and creation date

Solved
blop135 -  
 blop135 -
Hello everyone,

I'm trying to create a script to list the files in a folder along with their creation dates. I must admit I'm really bad at this^^, so basically what I want is to be able to type in the path of the folder where I can list all the files inside when I run the script.

So far I've done this somewhat randomly:

@echo off
echo Enter path
set /p path=
cd %path%
dir /TC *.* /B > list.txt
exit 0

But obviously that's failing because it's not finding the path at all; wouldn't it be more about PATH?

I know it's not necessarily very clear, but if anyone has 2-3 ideas, that would be great.

Thanks in advance ;)

3 answers

  1. barnabe0057 Posted messages 14329 Registration date   Status Contributor Last intervention   4 930
     
    Good evening,

    Try it like this:

    @echo off
    setlocal enableextensions

    :start
    cls & set "path="
    echo. & echo Enter the access path
    set /p "path=### "
    if not exist "%path%" (goto :start)

    dir /TC /B /A-D "%path%" > list.txt
    notepad list.txt
    exit /B


    “Artificial intelligence is defined as the opposite of natural stupidity.”
    1
  2. blop135
     
    Nifty, do you think it's possible to add the creation date of each file/folder in the .txt?

    Thank you ;)
    0
    1. barnabe0057 Posted messages 14329 Registration date   Status Contributor Last intervention   4 930
       
      As such:
      @echo off
      setlocal enableextensions

      :start
      cls & set "path="
      echo. & echo Enter the access path
      set /p "path=### "
      if not exist "%path%" (goto :start)

      dir /TC "%path%" > list.txt
      notepad list.txt
      exit /B
      0