How to automatically update folder modified date in Windows












3















In Windows, is there a way to update automatically (or with a simple script) the date of a folder with the latest modified date of any of its files (recursive)?










share|improve this question





























    3















    In Windows, is there a way to update automatically (or with a simple script) the date of a folder with the latest modified date of any of its files (recursive)?










    share|improve this question



























      3












      3








      3


      1






      In Windows, is there a way to update automatically (or with a simple script) the date of a folder with the latest modified date of any of its files (recursive)?










      share|improve this question
















      In Windows, is there a way to update automatically (or with a simple script) the date of a folder with the latest modified date of any of its files (recursive)?







      windows






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 29 '14 at 12:04









      Der Hochstapler

      68.2k50230286




      68.2k50230286










      asked Jun 1 '10 at 9:05









      NotitzeNotitze

      55661124




      55661124






















          7 Answers
          7






          active

          oldest

          votes


















          4














          You can do this in PowerShell. Something like this to update the current folder based on files it directly contains:



          $lastModified = (dir . | ?{!$_.PSIsContainer} | sort LastWriteTime | select -last 1).LastWriteTime
          $folder = get-item .
          $folder.LastWriteTime = $lastModified


          (This will fail if there are no files in the folder or if the user does not have suitable permissions.)



          EDIT: Ensure only one file (the last) is found so sort pipeline has a singular result.






          share|improve this answer


























          • on Win7 I get the error Exception setting "LastWriteTime": "Cannot convert null to type "System.DateTime"." when running this. It has to do with the first line, the .LastWriteTime suffix is resolving to null. Removing it creates a value for $lastmodified, but not the one we want.

            – matt wilkie
            May 26 '11 at 17:24











          • solved first line, one needs to grab first item from list and not the list itself: $fileList = (dir . | ?{!$_.PSIsContainer} | sort LastWriteTime), followed by $lastModified = $fileList[0].LastWriteTime. Still doesn't work though, setting the last mod time says Exception setting "LastWriteTime": "The process cannot access the file 'D:bugs' because it is being used by another process." but for the life of my I can't figure out what that process might be (and I've tried many different folders.) I think the offending process is itself!

            – matt wilkie
            May 26 '11 at 17:58











          • @Matt: fixed your first issue (forgot to only return a single item to get the date). For your second: it could be that PSH is holding the folder open, I would use Handles or Process Explorer (both Sysinternals) to determine what has the folder open.

            – Richard
            May 27 '11 at 8:04



















          2














          I just did a simple test - if you create an empty file in the directory, it changes the folder modified date to to that time. When you delete the file, that still counts as a modification, so it stays modified at that time.



          To do so recursively, you'd have to create an empty file in every folder you wish to have the date changed in. This is still a fairly simple solution if you're willing to do some simple programming.



          If you want to change the date to something other than the current time, this solution obviously will not work.






          share|improve this answer































            1














            You can use Bulk File Changer.




            BulkFileChanger is a small utility
            that allows you to create files list
            from multiple folders, and then make
            some action on them - Modify their
            created/modified/accessed time, change
            their file attribute (Read Only,
            Hidden, System), run an executable
            with these files as parameter, and
            copy/cut paste into Explorer.




            alt text






            share|improve this answer


























            • would this require manual intervention other than running it of course?

              – Notitze
              Jun 1 '10 at 9:16






            • 1





              +1 for highlighting a useful utility that can change file and folder dates. -1 that it can't be used in the manner asked for (set folder date based on contents, recursively)

              – matt wilkie
              May 26 '11 at 17:06











            • Indeed, this is a good program by Nir Sofer, but the folder mod/creation date can only be set manually. Nir wrote another program which does this much more elegantly, see my answer on FolderTimeUpdate.

              – chronometric
              Jun 4 '18 at 3:05



















            0














            Not pretty, but functional. Done in bash / cygwin



            ==================
            find -maxdepth 1 -type d | grep -v "^.$" | while read D ; do
            cd "$D"
            F=`ls -1tr | tail -1`
            cd ..
            touch -r "$D/$F" "$D"
            done
            ==================


            Brian






            share|improve this answer































              0














              Here is a modified version of Richard's answer. It's also PowerShell script. Instead of setting the modified time of the current directory, it sets the modified time of all first-level subdirectories of the current directory. Another difference is that it looks recursively for the last modified time. Hope it's helpful for someone else.



              $parentPath = Get-Location
              Get-ChildItem | where {$_.PsIsContainer} | foreach {
              cd -LiteralPath $_.FullName
              $files = dir -Recurse . | where {-Not $_.PsIsContainer}
              if ($files.Count -eq 0) {
              echo "note: $($_.Name) contains no files"
              } else {
              $_.LastWriteTime = ($files | sort LastWriteTime | select -last 1).LastWriteTime
              }
              }
              cd -LiteralPath $parentPath





              share|improve this answer































                0














                Do Nothing! Mission accomplished!



                The last modified date of a folder is always that of the last modified file in it.






                share|improve this answer
























                • If the last modified file has been deleted/moved, the date doesn't go back, so in some cases, this doesn't work if you want to have the date of the last modified file currently in the folder.

                  – satibel
                  Apr 3 '17 at 8:20











                • The OP said "update" not "postdate".

                  – user477799
                  Apr 3 '17 at 8:21











                • It also doesn't work recursively at least on windows 7 with the structure 123.exe 1 and 2 are from 2016 I've pasted 3.exe which is from 2003 result: 1 is still in 2016 2 is in 2017 3.exe is in 2003.

                  – satibel
                  Apr 3 '17 at 8:37





















                0














                FolderTimeUpdate



                Really good choice for non-scripting program. Aside from not being configurably automatic (in the GUI), its functionality is exactly that desired:




                FolderTimeUpdate is a simple tool for Windows that scans all files and
                folders under the base folder you choose, and updates the 'Modified
                Time' of every folder according the latest modified time of the files
                stored in it
                .




                enter image description here



                Most of this can be accomplished on the command line as well, so conceivably you could automate it by setting it to run at intervals, or perhaps even monitor certain folders.



                The GUI allows control of subfolder depth to recurse, inclusion and exclusion wildcards, and even whether to change the file creation time also (same as modified time, or match oldest creation or modified time).



                Program by the excellent and prolific Nir Sofer (the same author of Bulk File Changer in a less relevant answer).






                share|improve this answer

























                  Your Answer








                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "3"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f147524%2fhow-to-automatically-update-folder-modified-date-in-windows%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  7 Answers
                  7






                  active

                  oldest

                  votes








                  7 Answers
                  7






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  4














                  You can do this in PowerShell. Something like this to update the current folder based on files it directly contains:



                  $lastModified = (dir . | ?{!$_.PSIsContainer} | sort LastWriteTime | select -last 1).LastWriteTime
                  $folder = get-item .
                  $folder.LastWriteTime = $lastModified


                  (This will fail if there are no files in the folder or if the user does not have suitable permissions.)



                  EDIT: Ensure only one file (the last) is found so sort pipeline has a singular result.






                  share|improve this answer


























                  • on Win7 I get the error Exception setting "LastWriteTime": "Cannot convert null to type "System.DateTime"." when running this. It has to do with the first line, the .LastWriteTime suffix is resolving to null. Removing it creates a value for $lastmodified, but not the one we want.

                    – matt wilkie
                    May 26 '11 at 17:24











                  • solved first line, one needs to grab first item from list and not the list itself: $fileList = (dir . | ?{!$_.PSIsContainer} | sort LastWriteTime), followed by $lastModified = $fileList[0].LastWriteTime. Still doesn't work though, setting the last mod time says Exception setting "LastWriteTime": "The process cannot access the file 'D:bugs' because it is being used by another process." but for the life of my I can't figure out what that process might be (and I've tried many different folders.) I think the offending process is itself!

                    – matt wilkie
                    May 26 '11 at 17:58











                  • @Matt: fixed your first issue (forgot to only return a single item to get the date). For your second: it could be that PSH is holding the folder open, I would use Handles or Process Explorer (both Sysinternals) to determine what has the folder open.

                    – Richard
                    May 27 '11 at 8:04
















                  4














                  You can do this in PowerShell. Something like this to update the current folder based on files it directly contains:



                  $lastModified = (dir . | ?{!$_.PSIsContainer} | sort LastWriteTime | select -last 1).LastWriteTime
                  $folder = get-item .
                  $folder.LastWriteTime = $lastModified


                  (This will fail if there are no files in the folder or if the user does not have suitable permissions.)



                  EDIT: Ensure only one file (the last) is found so sort pipeline has a singular result.






                  share|improve this answer


























                  • on Win7 I get the error Exception setting "LastWriteTime": "Cannot convert null to type "System.DateTime"." when running this. It has to do with the first line, the .LastWriteTime suffix is resolving to null. Removing it creates a value for $lastmodified, but not the one we want.

                    – matt wilkie
                    May 26 '11 at 17:24











                  • solved first line, one needs to grab first item from list and not the list itself: $fileList = (dir . | ?{!$_.PSIsContainer} | sort LastWriteTime), followed by $lastModified = $fileList[0].LastWriteTime. Still doesn't work though, setting the last mod time says Exception setting "LastWriteTime": "The process cannot access the file 'D:bugs' because it is being used by another process." but for the life of my I can't figure out what that process might be (and I've tried many different folders.) I think the offending process is itself!

                    – matt wilkie
                    May 26 '11 at 17:58











                  • @Matt: fixed your first issue (forgot to only return a single item to get the date). For your second: it could be that PSH is holding the folder open, I would use Handles or Process Explorer (both Sysinternals) to determine what has the folder open.

                    – Richard
                    May 27 '11 at 8:04














                  4












                  4








                  4







                  You can do this in PowerShell. Something like this to update the current folder based on files it directly contains:



                  $lastModified = (dir . | ?{!$_.PSIsContainer} | sort LastWriteTime | select -last 1).LastWriteTime
                  $folder = get-item .
                  $folder.LastWriteTime = $lastModified


                  (This will fail if there are no files in the folder or if the user does not have suitable permissions.)



                  EDIT: Ensure only one file (the last) is found so sort pipeline has a singular result.






                  share|improve this answer















                  You can do this in PowerShell. Something like this to update the current folder based on files it directly contains:



                  $lastModified = (dir . | ?{!$_.PSIsContainer} | sort LastWriteTime | select -last 1).LastWriteTime
                  $folder = get-item .
                  $folder.LastWriteTime = $lastModified


                  (This will fail if there are no files in the folder or if the user does not have suitable permissions.)



                  EDIT: Ensure only one file (the last) is found so sort pipeline has a singular result.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited May 27 '11 at 8:02

























                  answered Jun 1 '10 at 9:54









                  RichardRichard

                  7,81431926




                  7,81431926













                  • on Win7 I get the error Exception setting "LastWriteTime": "Cannot convert null to type "System.DateTime"." when running this. It has to do with the first line, the .LastWriteTime suffix is resolving to null. Removing it creates a value for $lastmodified, but not the one we want.

                    – matt wilkie
                    May 26 '11 at 17:24











                  • solved first line, one needs to grab first item from list and not the list itself: $fileList = (dir . | ?{!$_.PSIsContainer} | sort LastWriteTime), followed by $lastModified = $fileList[0].LastWriteTime. Still doesn't work though, setting the last mod time says Exception setting "LastWriteTime": "The process cannot access the file 'D:bugs' because it is being used by another process." but for the life of my I can't figure out what that process might be (and I've tried many different folders.) I think the offending process is itself!

                    – matt wilkie
                    May 26 '11 at 17:58











                  • @Matt: fixed your first issue (forgot to only return a single item to get the date). For your second: it could be that PSH is holding the folder open, I would use Handles or Process Explorer (both Sysinternals) to determine what has the folder open.

                    – Richard
                    May 27 '11 at 8:04



















                  • on Win7 I get the error Exception setting "LastWriteTime": "Cannot convert null to type "System.DateTime"." when running this. It has to do with the first line, the .LastWriteTime suffix is resolving to null. Removing it creates a value for $lastmodified, but not the one we want.

                    – matt wilkie
                    May 26 '11 at 17:24











                  • solved first line, one needs to grab first item from list and not the list itself: $fileList = (dir . | ?{!$_.PSIsContainer} | sort LastWriteTime), followed by $lastModified = $fileList[0].LastWriteTime. Still doesn't work though, setting the last mod time says Exception setting "LastWriteTime": "The process cannot access the file 'D:bugs' because it is being used by another process." but for the life of my I can't figure out what that process might be (and I've tried many different folders.) I think the offending process is itself!

                    – matt wilkie
                    May 26 '11 at 17:58











                  • @Matt: fixed your first issue (forgot to only return a single item to get the date). For your second: it could be that PSH is holding the folder open, I would use Handles or Process Explorer (both Sysinternals) to determine what has the folder open.

                    – Richard
                    May 27 '11 at 8:04

















                  on Win7 I get the error Exception setting "LastWriteTime": "Cannot convert null to type "System.DateTime"." when running this. It has to do with the first line, the .LastWriteTime suffix is resolving to null. Removing it creates a value for $lastmodified, but not the one we want.

                  – matt wilkie
                  May 26 '11 at 17:24





                  on Win7 I get the error Exception setting "LastWriteTime": "Cannot convert null to type "System.DateTime"." when running this. It has to do with the first line, the .LastWriteTime suffix is resolving to null. Removing it creates a value for $lastmodified, but not the one we want.

                  – matt wilkie
                  May 26 '11 at 17:24













                  solved first line, one needs to grab first item from list and not the list itself: $fileList = (dir . | ?{!$_.PSIsContainer} | sort LastWriteTime), followed by $lastModified = $fileList[0].LastWriteTime. Still doesn't work though, setting the last mod time says Exception setting "LastWriteTime": "The process cannot access the file 'D:bugs' because it is being used by another process." but for the life of my I can't figure out what that process might be (and I've tried many different folders.) I think the offending process is itself!

                  – matt wilkie
                  May 26 '11 at 17:58





                  solved first line, one needs to grab first item from list and not the list itself: $fileList = (dir . | ?{!$_.PSIsContainer} | sort LastWriteTime), followed by $lastModified = $fileList[0].LastWriteTime. Still doesn't work though, setting the last mod time says Exception setting "LastWriteTime": "The process cannot access the file 'D:bugs' because it is being used by another process." but for the life of my I can't figure out what that process might be (and I've tried many different folders.) I think the offending process is itself!

                  – matt wilkie
                  May 26 '11 at 17:58













                  @Matt: fixed your first issue (forgot to only return a single item to get the date). For your second: it could be that PSH is holding the folder open, I would use Handles or Process Explorer (both Sysinternals) to determine what has the folder open.

                  – Richard
                  May 27 '11 at 8:04





                  @Matt: fixed your first issue (forgot to only return a single item to get the date). For your second: it could be that PSH is holding the folder open, I would use Handles or Process Explorer (both Sysinternals) to determine what has the folder open.

                  – Richard
                  May 27 '11 at 8:04













                  2














                  I just did a simple test - if you create an empty file in the directory, it changes the folder modified date to to that time. When you delete the file, that still counts as a modification, so it stays modified at that time.



                  To do so recursively, you'd have to create an empty file in every folder you wish to have the date changed in. This is still a fairly simple solution if you're willing to do some simple programming.



                  If you want to change the date to something other than the current time, this solution obviously will not work.






                  share|improve this answer




























                    2














                    I just did a simple test - if you create an empty file in the directory, it changes the folder modified date to to that time. When you delete the file, that still counts as a modification, so it stays modified at that time.



                    To do so recursively, you'd have to create an empty file in every folder you wish to have the date changed in. This is still a fairly simple solution if you're willing to do some simple programming.



                    If you want to change the date to something other than the current time, this solution obviously will not work.






                    share|improve this answer


























                      2












                      2








                      2







                      I just did a simple test - if you create an empty file in the directory, it changes the folder modified date to to that time. When you delete the file, that still counts as a modification, so it stays modified at that time.



                      To do so recursively, you'd have to create an empty file in every folder you wish to have the date changed in. This is still a fairly simple solution if you're willing to do some simple programming.



                      If you want to change the date to something other than the current time, this solution obviously will not work.






                      share|improve this answer













                      I just did a simple test - if you create an empty file in the directory, it changes the folder modified date to to that time. When you delete the file, that still counts as a modification, so it stays modified at that time.



                      To do so recursively, you'd have to create an empty file in every folder you wish to have the date changed in. This is still a fairly simple solution if you're willing to do some simple programming.



                      If you want to change the date to something other than the current time, this solution obviously will not work.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Oct 5 '13 at 16:55









                      Lyle BrownLyle Brown

                      34328




                      34328























                          1














                          You can use Bulk File Changer.




                          BulkFileChanger is a small utility
                          that allows you to create files list
                          from multiple folders, and then make
                          some action on them - Modify their
                          created/modified/accessed time, change
                          their file attribute (Read Only,
                          Hidden, System), run an executable
                          with these files as parameter, and
                          copy/cut paste into Explorer.




                          alt text






                          share|improve this answer


























                          • would this require manual intervention other than running it of course?

                            – Notitze
                            Jun 1 '10 at 9:16






                          • 1





                            +1 for highlighting a useful utility that can change file and folder dates. -1 that it can't be used in the manner asked for (set folder date based on contents, recursively)

                            – matt wilkie
                            May 26 '11 at 17:06











                          • Indeed, this is a good program by Nir Sofer, but the folder mod/creation date can only be set manually. Nir wrote another program which does this much more elegantly, see my answer on FolderTimeUpdate.

                            – chronometric
                            Jun 4 '18 at 3:05
















                          1














                          You can use Bulk File Changer.




                          BulkFileChanger is a small utility
                          that allows you to create files list
                          from multiple folders, and then make
                          some action on them - Modify their
                          created/modified/accessed time, change
                          their file attribute (Read Only,
                          Hidden, System), run an executable
                          with these files as parameter, and
                          copy/cut paste into Explorer.




                          alt text






                          share|improve this answer


























                          • would this require manual intervention other than running it of course?

                            – Notitze
                            Jun 1 '10 at 9:16






                          • 1





                            +1 for highlighting a useful utility that can change file and folder dates. -1 that it can't be used in the manner asked for (set folder date based on contents, recursively)

                            – matt wilkie
                            May 26 '11 at 17:06











                          • Indeed, this is a good program by Nir Sofer, but the folder mod/creation date can only be set manually. Nir wrote another program which does this much more elegantly, see my answer on FolderTimeUpdate.

                            – chronometric
                            Jun 4 '18 at 3:05














                          1












                          1








                          1







                          You can use Bulk File Changer.




                          BulkFileChanger is a small utility
                          that allows you to create files list
                          from multiple folders, and then make
                          some action on them - Modify their
                          created/modified/accessed time, change
                          their file attribute (Read Only,
                          Hidden, System), run an executable
                          with these files as parameter, and
                          copy/cut paste into Explorer.




                          alt text






                          share|improve this answer















                          You can use Bulk File Changer.




                          BulkFileChanger is a small utility
                          that allows you to create files list
                          from multiple folders, and then make
                          some action on them - Modify their
                          created/modified/accessed time, change
                          their file attribute (Read Only,
                          Hidden, System), run an executable
                          with these files as parameter, and
                          copy/cut paste into Explorer.




                          alt text







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Aug 19 '11 at 2:51









                          3498DB

                          15.8k114762




                          15.8k114762










                          answered Jun 1 '10 at 9:10









                          Mehper C. PalavuzlarMehper C. Palavuzlar

                          43.7k42176233




                          43.7k42176233













                          • would this require manual intervention other than running it of course?

                            – Notitze
                            Jun 1 '10 at 9:16






                          • 1





                            +1 for highlighting a useful utility that can change file and folder dates. -1 that it can't be used in the manner asked for (set folder date based on contents, recursively)

                            – matt wilkie
                            May 26 '11 at 17:06











                          • Indeed, this is a good program by Nir Sofer, but the folder mod/creation date can only be set manually. Nir wrote another program which does this much more elegantly, see my answer on FolderTimeUpdate.

                            – chronometric
                            Jun 4 '18 at 3:05



















                          • would this require manual intervention other than running it of course?

                            – Notitze
                            Jun 1 '10 at 9:16






                          • 1





                            +1 for highlighting a useful utility that can change file and folder dates. -1 that it can't be used in the manner asked for (set folder date based on contents, recursively)

                            – matt wilkie
                            May 26 '11 at 17:06











                          • Indeed, this is a good program by Nir Sofer, but the folder mod/creation date can only be set manually. Nir wrote another program which does this much more elegantly, see my answer on FolderTimeUpdate.

                            – chronometric
                            Jun 4 '18 at 3:05

















                          would this require manual intervention other than running it of course?

                          – Notitze
                          Jun 1 '10 at 9:16





                          would this require manual intervention other than running it of course?

                          – Notitze
                          Jun 1 '10 at 9:16




                          1




                          1





                          +1 for highlighting a useful utility that can change file and folder dates. -1 that it can't be used in the manner asked for (set folder date based on contents, recursively)

                          – matt wilkie
                          May 26 '11 at 17:06





                          +1 for highlighting a useful utility that can change file and folder dates. -1 that it can't be used in the manner asked for (set folder date based on contents, recursively)

                          – matt wilkie
                          May 26 '11 at 17:06













                          Indeed, this is a good program by Nir Sofer, but the folder mod/creation date can only be set manually. Nir wrote another program which does this much more elegantly, see my answer on FolderTimeUpdate.

                          – chronometric
                          Jun 4 '18 at 3:05





                          Indeed, this is a good program by Nir Sofer, but the folder mod/creation date can only be set manually. Nir wrote another program which does this much more elegantly, see my answer on FolderTimeUpdate.

                          – chronometric
                          Jun 4 '18 at 3:05











                          0














                          Not pretty, but functional. Done in bash / cygwin



                          ==================
                          find -maxdepth 1 -type d | grep -v "^.$" | while read D ; do
                          cd "$D"
                          F=`ls -1tr | tail -1`
                          cd ..
                          touch -r "$D/$F" "$D"
                          done
                          ==================


                          Brian






                          share|improve this answer




























                            0














                            Not pretty, but functional. Done in bash / cygwin



                            ==================
                            find -maxdepth 1 -type d | grep -v "^.$" | while read D ; do
                            cd "$D"
                            F=`ls -1tr | tail -1`
                            cd ..
                            touch -r "$D/$F" "$D"
                            done
                            ==================


                            Brian






                            share|improve this answer


























                              0












                              0








                              0







                              Not pretty, but functional. Done in bash / cygwin



                              ==================
                              find -maxdepth 1 -type d | grep -v "^.$" | while read D ; do
                              cd "$D"
                              F=`ls -1tr | tail -1`
                              cd ..
                              touch -r "$D/$F" "$D"
                              done
                              ==================


                              Brian






                              share|improve this answer













                              Not pretty, but functional. Done in bash / cygwin



                              ==================
                              find -maxdepth 1 -type d | grep -v "^.$" | while read D ; do
                              cd "$D"
                              F=`ls -1tr | tail -1`
                              cd ..
                              touch -r "$D/$F" "$D"
                              done
                              ==================


                              Brian







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Oct 5 '13 at 16:51









                              bdpbdp

                              1




                              1























                                  0














                                  Here is a modified version of Richard's answer. It's also PowerShell script. Instead of setting the modified time of the current directory, it sets the modified time of all first-level subdirectories of the current directory. Another difference is that it looks recursively for the last modified time. Hope it's helpful for someone else.



                                  $parentPath = Get-Location
                                  Get-ChildItem | where {$_.PsIsContainer} | foreach {
                                  cd -LiteralPath $_.FullName
                                  $files = dir -Recurse . | where {-Not $_.PsIsContainer}
                                  if ($files.Count -eq 0) {
                                  echo "note: $($_.Name) contains no files"
                                  } else {
                                  $_.LastWriteTime = ($files | sort LastWriteTime | select -last 1).LastWriteTime
                                  }
                                  }
                                  cd -LiteralPath $parentPath





                                  share|improve this answer




























                                    0














                                    Here is a modified version of Richard's answer. It's also PowerShell script. Instead of setting the modified time of the current directory, it sets the modified time of all first-level subdirectories of the current directory. Another difference is that it looks recursively for the last modified time. Hope it's helpful for someone else.



                                    $parentPath = Get-Location
                                    Get-ChildItem | where {$_.PsIsContainer} | foreach {
                                    cd -LiteralPath $_.FullName
                                    $files = dir -Recurse . | where {-Not $_.PsIsContainer}
                                    if ($files.Count -eq 0) {
                                    echo "note: $($_.Name) contains no files"
                                    } else {
                                    $_.LastWriteTime = ($files | sort LastWriteTime | select -last 1).LastWriteTime
                                    }
                                    }
                                    cd -LiteralPath $parentPath





                                    share|improve this answer


























                                      0












                                      0








                                      0







                                      Here is a modified version of Richard's answer. It's also PowerShell script. Instead of setting the modified time of the current directory, it sets the modified time of all first-level subdirectories of the current directory. Another difference is that it looks recursively for the last modified time. Hope it's helpful for someone else.



                                      $parentPath = Get-Location
                                      Get-ChildItem | where {$_.PsIsContainer} | foreach {
                                      cd -LiteralPath $_.FullName
                                      $files = dir -Recurse . | where {-Not $_.PsIsContainer}
                                      if ($files.Count -eq 0) {
                                      echo "note: $($_.Name) contains no files"
                                      } else {
                                      $_.LastWriteTime = ($files | sort LastWriteTime | select -last 1).LastWriteTime
                                      }
                                      }
                                      cd -LiteralPath $parentPath





                                      share|improve this answer













                                      Here is a modified version of Richard's answer. It's also PowerShell script. Instead of setting the modified time of the current directory, it sets the modified time of all first-level subdirectories of the current directory. Another difference is that it looks recursively for the last modified time. Hope it's helpful for someone else.



                                      $parentPath = Get-Location
                                      Get-ChildItem | where {$_.PsIsContainer} | foreach {
                                      cd -LiteralPath $_.FullName
                                      $files = dir -Recurse . | where {-Not $_.PsIsContainer}
                                      if ($files.Count -eq 0) {
                                      echo "note: $($_.Name) contains no files"
                                      } else {
                                      $_.LastWriteTime = ($files | sort LastWriteTime | select -last 1).LastWriteTime
                                      }
                                      }
                                      cd -LiteralPath $parentPath






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Jan 1 '17 at 20:36









                                      ArcindeArcinde

                                      1164




                                      1164























                                          0














                                          Do Nothing! Mission accomplished!



                                          The last modified date of a folder is always that of the last modified file in it.






                                          share|improve this answer
























                                          • If the last modified file has been deleted/moved, the date doesn't go back, so in some cases, this doesn't work if you want to have the date of the last modified file currently in the folder.

                                            – satibel
                                            Apr 3 '17 at 8:20











                                          • The OP said "update" not "postdate".

                                            – user477799
                                            Apr 3 '17 at 8:21











                                          • It also doesn't work recursively at least on windows 7 with the structure 123.exe 1 and 2 are from 2016 I've pasted 3.exe which is from 2003 result: 1 is still in 2016 2 is in 2017 3.exe is in 2003.

                                            – satibel
                                            Apr 3 '17 at 8:37


















                                          0














                                          Do Nothing! Mission accomplished!



                                          The last modified date of a folder is always that of the last modified file in it.






                                          share|improve this answer
























                                          • If the last modified file has been deleted/moved, the date doesn't go back, so in some cases, this doesn't work if you want to have the date of the last modified file currently in the folder.

                                            – satibel
                                            Apr 3 '17 at 8:20











                                          • The OP said "update" not "postdate".

                                            – user477799
                                            Apr 3 '17 at 8:21











                                          • It also doesn't work recursively at least on windows 7 with the structure 123.exe 1 and 2 are from 2016 I've pasted 3.exe which is from 2003 result: 1 is still in 2016 2 is in 2017 3.exe is in 2003.

                                            – satibel
                                            Apr 3 '17 at 8:37
















                                          0












                                          0








                                          0







                                          Do Nothing! Mission accomplished!



                                          The last modified date of a folder is always that of the last modified file in it.






                                          share|improve this answer













                                          Do Nothing! Mission accomplished!



                                          The last modified date of a folder is always that of the last modified file in it.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Apr 3 '17 at 8:02







                                          user477799




















                                          • If the last modified file has been deleted/moved, the date doesn't go back, so in some cases, this doesn't work if you want to have the date of the last modified file currently in the folder.

                                            – satibel
                                            Apr 3 '17 at 8:20











                                          • The OP said "update" not "postdate".

                                            – user477799
                                            Apr 3 '17 at 8:21











                                          • It also doesn't work recursively at least on windows 7 with the structure 123.exe 1 and 2 are from 2016 I've pasted 3.exe which is from 2003 result: 1 is still in 2016 2 is in 2017 3.exe is in 2003.

                                            – satibel
                                            Apr 3 '17 at 8:37





















                                          • If the last modified file has been deleted/moved, the date doesn't go back, so in some cases, this doesn't work if you want to have the date of the last modified file currently in the folder.

                                            – satibel
                                            Apr 3 '17 at 8:20











                                          • The OP said "update" not "postdate".

                                            – user477799
                                            Apr 3 '17 at 8:21











                                          • It also doesn't work recursively at least on windows 7 with the structure 123.exe 1 and 2 are from 2016 I've pasted 3.exe which is from 2003 result: 1 is still in 2016 2 is in 2017 3.exe is in 2003.

                                            – satibel
                                            Apr 3 '17 at 8:37



















                                          If the last modified file has been deleted/moved, the date doesn't go back, so in some cases, this doesn't work if you want to have the date of the last modified file currently in the folder.

                                          – satibel
                                          Apr 3 '17 at 8:20





                                          If the last modified file has been deleted/moved, the date doesn't go back, so in some cases, this doesn't work if you want to have the date of the last modified file currently in the folder.

                                          – satibel
                                          Apr 3 '17 at 8:20













                                          The OP said "update" not "postdate".

                                          – user477799
                                          Apr 3 '17 at 8:21





                                          The OP said "update" not "postdate".

                                          – user477799
                                          Apr 3 '17 at 8:21













                                          It also doesn't work recursively at least on windows 7 with the structure 123.exe 1 and 2 are from 2016 I've pasted 3.exe which is from 2003 result: 1 is still in 2016 2 is in 2017 3.exe is in 2003.

                                          – satibel
                                          Apr 3 '17 at 8:37







                                          It also doesn't work recursively at least on windows 7 with the structure 123.exe 1 and 2 are from 2016 I've pasted 3.exe which is from 2003 result: 1 is still in 2016 2 is in 2017 3.exe is in 2003.

                                          – satibel
                                          Apr 3 '17 at 8:37













                                          0














                                          FolderTimeUpdate



                                          Really good choice for non-scripting program. Aside from not being configurably automatic (in the GUI), its functionality is exactly that desired:




                                          FolderTimeUpdate is a simple tool for Windows that scans all files and
                                          folders under the base folder you choose, and updates the 'Modified
                                          Time' of every folder according the latest modified time of the files
                                          stored in it
                                          .




                                          enter image description here



                                          Most of this can be accomplished on the command line as well, so conceivably you could automate it by setting it to run at intervals, or perhaps even monitor certain folders.



                                          The GUI allows control of subfolder depth to recurse, inclusion and exclusion wildcards, and even whether to change the file creation time also (same as modified time, or match oldest creation or modified time).



                                          Program by the excellent and prolific Nir Sofer (the same author of Bulk File Changer in a less relevant answer).






                                          share|improve this answer






























                                            0














                                            FolderTimeUpdate



                                            Really good choice for non-scripting program. Aside from not being configurably automatic (in the GUI), its functionality is exactly that desired:




                                            FolderTimeUpdate is a simple tool for Windows that scans all files and
                                            folders under the base folder you choose, and updates the 'Modified
                                            Time' of every folder according the latest modified time of the files
                                            stored in it
                                            .




                                            enter image description here



                                            Most of this can be accomplished on the command line as well, so conceivably you could automate it by setting it to run at intervals, or perhaps even monitor certain folders.



                                            The GUI allows control of subfolder depth to recurse, inclusion and exclusion wildcards, and even whether to change the file creation time also (same as modified time, or match oldest creation or modified time).



                                            Program by the excellent and prolific Nir Sofer (the same author of Bulk File Changer in a less relevant answer).






                                            share|improve this answer




























                                              0












                                              0








                                              0







                                              FolderTimeUpdate



                                              Really good choice for non-scripting program. Aside from not being configurably automatic (in the GUI), its functionality is exactly that desired:




                                              FolderTimeUpdate is a simple tool for Windows that scans all files and
                                              folders under the base folder you choose, and updates the 'Modified
                                              Time' of every folder according the latest modified time of the files
                                              stored in it
                                              .




                                              enter image description here



                                              Most of this can be accomplished on the command line as well, so conceivably you could automate it by setting it to run at intervals, or perhaps even monitor certain folders.



                                              The GUI allows control of subfolder depth to recurse, inclusion and exclusion wildcards, and even whether to change the file creation time also (same as modified time, or match oldest creation or modified time).



                                              Program by the excellent and prolific Nir Sofer (the same author of Bulk File Changer in a less relevant answer).






                                              share|improve this answer















                                              FolderTimeUpdate



                                              Really good choice for non-scripting program. Aside from not being configurably automatic (in the GUI), its functionality is exactly that desired:




                                              FolderTimeUpdate is a simple tool for Windows that scans all files and
                                              folders under the base folder you choose, and updates the 'Modified
                                              Time' of every folder according the latest modified time of the files
                                              stored in it
                                              .




                                              enter image description here



                                              Most of this can be accomplished on the command line as well, so conceivably you could automate it by setting it to run at intervals, or perhaps even monitor certain folders.



                                              The GUI allows control of subfolder depth to recurse, inclusion and exclusion wildcards, and even whether to change the file creation time also (same as modified time, or match oldest creation or modified time).



                                              Program by the excellent and prolific Nir Sofer (the same author of Bulk File Changer in a less relevant answer).







                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited Feb 9 at 3:57

























                                              answered Jun 4 '18 at 3:02









                                              chronometricchronometric

                                              1665




                                              1665






























                                                  draft saved

                                                  draft discarded




















































                                                  Thanks for contributing an answer to Super User!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function () {
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f147524%2fhow-to-automatically-update-folder-modified-date-in-windows%23new-answer', 'question_page');
                                                  }
                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  Mouse cursor on multiple screens with different PPI

                                                  Agildo Ribeiro

                                                  Sometime when accessing a menu: “Ubuntu 16.04 has experienced an internal error”