![]() The parameter /O-D results in getting output by DIR the found file names listed by date in reverse order from newest to oldest. ![]() In this case are output just the file names without path by command DIR never enclosed in " even on containing a space or one of these characters &()^= !'+,`~ which require the file name string to be enclosed in " on further processing it by cmd.exe on other command lines. The parameter /B turns on bare output format. The parameter /A-D makes sure ignoring subdirectories which unusually end by chance also with the string. The internal command DIR searches now for file system entries in the specified directory matching the wildcard pattern *.jpg with following additional restrictions. There is executed in this case in background with Windows installed into C:\Windows: C:\Windows\System32\cmd.exe /c DIR "C:\Jenkins\Releases\C9metro\*.jpg" /A-D /B /O-D /TW 2>nul The FOR loop can be also optimized to a single command line: FOR /F "eol=| delims=" %%I IN ('DIR "C:\Jenkins\Releases\C9metro\*.jpg" /A-D /B /O-D /TW 2^>nul') DO SET "NewestFile=%%I" & GOTO FoundFileįOR starts in background one more cmd.exe with option /c and the command line within ' appended as additional arguments. ![]() I suggest to use the following lines: FOR /F "eol=| delims=" %%I IN ('DIR "C:\Jenkins\Releases\C9metro\*.jpg" /A-D /B /O-D /TW 2^>nul') DO (ĮCHO Newest *.jpg file is: "%NewestFile%" ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |