Ask Your Question

Revision history [back]

To select multiple recently uploaded files using a batch file, you can use the following steps:

  1. Use the "dir" command to list all files in the directory and sort them by date in descending order:
dir /od /b >files.txt
  1. Use the "type" command to read the top N lines of the "files.txt" file (where N is the number of files you want to select):
set /p files=<files.txt
set /a counter=0
for /f "tokens=*" %%i in (files.txt) do (
    set /a counter+=1
    if !counter! leq N (
        set fileList=!fileList! "%%i"
    )
)
  1. Use the "echo" command to print the selected file names:
echo Selected files: %fileList%
  1. Use the "del" command to delete the "files.txt" file:
del files.txt

Note: Replace "N" with the number of files you want to select. Also, make sure to adjust the "dir" command to list only the files that were recently uploaded (e.g. using the "/tw" option to list files modified in the last N hours).