I'm referring to a batch script to create a list of files having file timestamp greater than specified date and store the list of pathnames in a text file. I want to use this to feed a process that needs to consume the files chronologically.
During my search, I came across this site that states
xcopy \rawdata \reports /d:12-29-1993 /l > xcopy.out"The file Xcopy.out lists every file that is to be copied."
Since, the content is no longer updated/supported, I want to know the default order in which the pathnames would be listed in my text file or if I can sort the pathnames myself before copying.
I do get a sorted filelist using the below but I need to confirm it will be so on every run as I have not mentioned any sort order explicitly (I don't know how to).
xcopy (source_dir) /l /s /d:(specified_date) .<myfileList.txt
I also want to know what the dot after specified date does.
So far, I have this information (from the same site):
when used with xcopy:
/l - Generates a list of files, does not actively copy them.
/s - Copies non-empty directories and subdirectories.
/d [:MM-DD-YYYY] - Copies source files changed on or after the specified date only. If not specified, copies all source files that are newer than existing destination files.
Any help is greatly appreciated.
This is one possible answer if you’re willing to change the date format on your system. You can use 'For', 'FORFILES' and 'Sort' to build a list of files.
This solution will sort files by date independent of their sub-directories.
Control Panel -> Region -> Additional Settings… -> Date(tab) -> Short Date = “yyyy-MM-dd”
C:\Temp>For /F "tokens=1,2 delims=^"^" %a in ('"FORFILES /P "C:\Temp" /S /D 2023-04-01 /C "cmd /c @echo @fdate @file" | sort"') do @echo %a %b
You can replace the "@echo" command at the end with another command using %b as the filename.