Shiva Kumar
Shiva Kumar

Reputation: 1

How to find the last created folder using batch script as I checkout the code from svn and my folder format is TEST1

I am automating folder creation by finding out last created

Steps:

  1. Ask for svn repo to enter
  2. Ask for rf number/Im number to enter
  3. Check the log for RfNumber whether it’s present or not
  4. If present then increment the folder with minor version suppose folder2 is present then make new folder2.1
  5. If not present then make major version folder 2 to 3
  6. In Step 5 it should read the folder as last created not last updated
  7. Ask for another repo2 to enter
  8. Copy contents from repo1 to repo2
  9. Commit

In my case, it is reading as:

test1,test11,test12,..test2,test21,..test3

When i arrange folders by name and I write the code to arrange the code by last updated, it is giving last commited folder as I am checkout the code from svn.

for /f "delims=" %%A in ('dir /ad /b /od') do set lastfolder=%%A
echo %lastfolder%

Upvotes: 0

Views: 40

Answers (1)

michael_heath
michael_heath

Reputation: 5372

for /f "delims=" %%A in ('dir /ad /b /od /tc') do set lastfolder=%%A
echo %lastfolder%

Those dir settings are giving me last modified. If you want last created, then add the argument /tc to change timefield to creation.

For cmd prompt, change %%A to %A.

See dir /?.

Upvotes: 1

Related Questions