Making a Dataset that emulates `ls -tlra`?Doubts on scripting: error messages when trying to run and how to process lots of filesGet the last line from each of a large number of files, transform them, and write all results to a single new fileUnable to import .m file in WSTPHow to workaround failures with Unicode filepaths?Convert variable name to filenameHow to read this dataset with .dat and .r64 files?Automatically making a path to the users directoryCleanest way to copy part of one directory to anotherBetter random (unique) file nameUsing Open with a filename that contains “:”

I have found a mistake on someone's code published online: what is the protocol?

Could a US citizen born through "birth tourism" become President?

How long were the Apollo astronauts allowed to breathe 100% oxygen at 1 atmosphere continuously?

Making a Dataset that emulates `ls -tlra`?

Why do space operations use "nominal" to mean "working correctly"?

Should I have shared a document with a former employee?

Should I have one hand on the throttle during engine ignition?

Which GPUs to get for Mathematical Optimization (if any)?

When will the last unambiguous evidence of mankind disappear?

Why is an object not defined as identity morphism?

How was Luke's prosthetic hand in Episode V filmed?

How to interpret a promising preprint that was never published in peer-review?

Do medium format lenses have a crop factor?

Did Hitler say this quote about homeschooling?

What is this green alien supposed to be on the American covers of the "Hitchhiker's Guide to the Galaxy"?

Why can't I hear fret buzz through the amp?

Does Holy Water deal damage on a failed attack roll?

Last-minute canceled work-trip mean I'll lose thousands of dollars on planned vacation

Do pedestrians imitate auto traffic?

Why don't humans perceive waves as twice the frequency they are?

Why do jet engines sound louder on the ground than inside the aircraft?

What is the name for the average of the largest and the smallest values in a given data set?

We get more abuse than anyone else

What would be the safest way to drop thousands of small, hard objects from a typical, high wing, GA airplane?



Making a Dataset that emulates `ls -tlra`?


Doubts on scripting: error messages when trying to run and how to process lots of filesGet the last line from each of a large number of files, transform them, and write all results to a single new fileUnable to import .m file in WSTPHow to workaround failures with Unicode filepaths?Convert variable name to filenameHow to read this dataset with .dat and .r64 files?Automatically making a path to the users directoryCleanest way to copy part of one directory to anotherBetter random (unique) file nameUsing Open with a filename that contains “:”






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








5












$begingroup$


When we ls -tlra in bash, we get filename information, size of files, date last modified, etc. Is there a way to create a Mathematica function which generates a Dataset of all of this information?



Some key functions here: FileNames[], FileDate[], FileSize[]. I'm not sure how to get information about file permissions, but that is less important.










share|improve this question









$endgroup$


















    5












    $begingroup$


    When we ls -tlra in bash, we get filename information, size of files, date last modified, etc. Is there a way to create a Mathematica function which generates a Dataset of all of this information?



    Some key functions here: FileNames[], FileDate[], FileSize[]. I'm not sure how to get information about file permissions, but that is less important.










    share|improve this question









    $endgroup$














      5












      5








      5


      1



      $begingroup$


      When we ls -tlra in bash, we get filename information, size of files, date last modified, etc. Is there a way to create a Mathematica function which generates a Dataset of all of this information?



      Some key functions here: FileNames[], FileDate[], FileSize[]. I'm not sure how to get information about file permissions, but that is less important.










      share|improve this question









      $endgroup$




      When we ls -tlra in bash, we get filename information, size of files, date last modified, etc. Is there a way to create a Mathematica function which generates a Dataset of all of this information?



      Some key functions here: FileNames[], FileDate[], FileSize[]. I'm not sure how to get information about file permissions, but that is less important.







      files-and-directories






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 10 hours ago









      GeorgeGeorge

      4931 silver badge9 bronze badges




      4931 silver badge9 bronze badges




















          2 Answers
          2






          active

          oldest

          votes


















          8












          $begingroup$

          Build your own



          Here I create a Dataset of files, taking advantage of the "Rules" option for FileDate. You can add your own information relevant for files or directories in the respective sections after DirectoryQ. Just as a playful example I added FileHash which may slows down things considerably.



          lstlra[dir_] := Dataset[
          <|(* For all files and directories *)
          "FileName" -> FileNameTake[#],
          "Type" -> FileType[#],
          FileDate[#, "Rules"],
          If[
          DirectoryQ[#],
          <|(* Directory only *)
          |>,
          <|(* Files only *)
          "FileSize" -> FileSize[#],
          "MD5-Hash" -> FileHash[#]
          |>
          ]
          |> & /@ FileNames[All, dir]
          ][SortBy["Modification"]]


          enter image description here




          Using File Information



          After the answer by @swish, was very nice to learn about Information applied to File. Here I just change the Head to and Association (using Apply @@) to allow you to put your own stuff. Unfortunately it has too much information, more than you possible need.



          lstlra2[dir_] := Dataset[
          <|
          Association @@ Information[File[#]],
          If[
          DirectoryQ[#],
          <|(* Directory only *)
          |>,
          <|(* Files only *)
          "MD5-Hash" -> FileHash[#]
          |>
          ]
          |> & /@ FileNames[All, dir]
          ][SortBy["LastModificationDate"]]





          share|improve this answer











          $endgroup$








          • 1




            $begingroup$
            Is there a way to have the final results sorted by date modified (this is also the behavior of ls -tlra I believe).
            $endgroup$
            – George
            9 hours ago










          • $begingroup$
            @George Oh, forgot about that, see last edit. I added [SortBy["Modification"]] and SortBy["LastModificationDate"] depending the function.
            $endgroup$
            – rhermans
            9 hours ago



















          7












          $begingroup$

          Try something like that



          props = "CreationDate", "UnixPermissionsString", "ByteCount";
          ls[dir_] :=
          Dataset@FileSystemMap[
          AssociationThread[props -> Information[File@#, props]] &, dir]





          share|improve this answer









          $endgroup$








          • 1




            $begingroup$
            Nice one! (+1) Thanks for introducing me to Information applied to File.
            $endgroup$
            – rhermans
            9 hours ago













          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "387"
          ;
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2fmathematica.stackexchange.com%2fquestions%2f202399%2fmaking-a-dataset-that-emulates-ls-tlra%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          8












          $begingroup$

          Build your own



          Here I create a Dataset of files, taking advantage of the "Rules" option for FileDate. You can add your own information relevant for files or directories in the respective sections after DirectoryQ. Just as a playful example I added FileHash which may slows down things considerably.



          lstlra[dir_] := Dataset[
          <|(* For all files and directories *)
          "FileName" -> FileNameTake[#],
          "Type" -> FileType[#],
          FileDate[#, "Rules"],
          If[
          DirectoryQ[#],
          <|(* Directory only *)
          |>,
          <|(* Files only *)
          "FileSize" -> FileSize[#],
          "MD5-Hash" -> FileHash[#]
          |>
          ]
          |> & /@ FileNames[All, dir]
          ][SortBy["Modification"]]


          enter image description here




          Using File Information



          After the answer by @swish, was very nice to learn about Information applied to File. Here I just change the Head to and Association (using Apply @@) to allow you to put your own stuff. Unfortunately it has too much information, more than you possible need.



          lstlra2[dir_] := Dataset[
          <|
          Association @@ Information[File[#]],
          If[
          DirectoryQ[#],
          <|(* Directory only *)
          |>,
          <|(* Files only *)
          "MD5-Hash" -> FileHash[#]
          |>
          ]
          |> & /@ FileNames[All, dir]
          ][SortBy["LastModificationDate"]]





          share|improve this answer











          $endgroup$








          • 1




            $begingroup$
            Is there a way to have the final results sorted by date modified (this is also the behavior of ls -tlra I believe).
            $endgroup$
            – George
            9 hours ago










          • $begingroup$
            @George Oh, forgot about that, see last edit. I added [SortBy["Modification"]] and SortBy["LastModificationDate"] depending the function.
            $endgroup$
            – rhermans
            9 hours ago
















          8












          $begingroup$

          Build your own



          Here I create a Dataset of files, taking advantage of the "Rules" option for FileDate. You can add your own information relevant for files or directories in the respective sections after DirectoryQ. Just as a playful example I added FileHash which may slows down things considerably.



          lstlra[dir_] := Dataset[
          <|(* For all files and directories *)
          "FileName" -> FileNameTake[#],
          "Type" -> FileType[#],
          FileDate[#, "Rules"],
          If[
          DirectoryQ[#],
          <|(* Directory only *)
          |>,
          <|(* Files only *)
          "FileSize" -> FileSize[#],
          "MD5-Hash" -> FileHash[#]
          |>
          ]
          |> & /@ FileNames[All, dir]
          ][SortBy["Modification"]]


          enter image description here




          Using File Information



          After the answer by @swish, was very nice to learn about Information applied to File. Here I just change the Head to and Association (using Apply @@) to allow you to put your own stuff. Unfortunately it has too much information, more than you possible need.



          lstlra2[dir_] := Dataset[
          <|
          Association @@ Information[File[#]],
          If[
          DirectoryQ[#],
          <|(* Directory only *)
          |>,
          <|(* Files only *)
          "MD5-Hash" -> FileHash[#]
          |>
          ]
          |> & /@ FileNames[All, dir]
          ][SortBy["LastModificationDate"]]





          share|improve this answer











          $endgroup$








          • 1




            $begingroup$
            Is there a way to have the final results sorted by date modified (this is also the behavior of ls -tlra I believe).
            $endgroup$
            – George
            9 hours ago










          • $begingroup$
            @George Oh, forgot about that, see last edit. I added [SortBy["Modification"]] and SortBy["LastModificationDate"] depending the function.
            $endgroup$
            – rhermans
            9 hours ago














          8












          8








          8





          $begingroup$

          Build your own



          Here I create a Dataset of files, taking advantage of the "Rules" option for FileDate. You can add your own information relevant for files or directories in the respective sections after DirectoryQ. Just as a playful example I added FileHash which may slows down things considerably.



          lstlra[dir_] := Dataset[
          <|(* For all files and directories *)
          "FileName" -> FileNameTake[#],
          "Type" -> FileType[#],
          FileDate[#, "Rules"],
          If[
          DirectoryQ[#],
          <|(* Directory only *)
          |>,
          <|(* Files only *)
          "FileSize" -> FileSize[#],
          "MD5-Hash" -> FileHash[#]
          |>
          ]
          |> & /@ FileNames[All, dir]
          ][SortBy["Modification"]]


          enter image description here




          Using File Information



          After the answer by @swish, was very nice to learn about Information applied to File. Here I just change the Head to and Association (using Apply @@) to allow you to put your own stuff. Unfortunately it has too much information, more than you possible need.



          lstlra2[dir_] := Dataset[
          <|
          Association @@ Information[File[#]],
          If[
          DirectoryQ[#],
          <|(* Directory only *)
          |>,
          <|(* Files only *)
          "MD5-Hash" -> FileHash[#]
          |>
          ]
          |> & /@ FileNames[All, dir]
          ][SortBy["LastModificationDate"]]





          share|improve this answer











          $endgroup$



          Build your own



          Here I create a Dataset of files, taking advantage of the "Rules" option for FileDate. You can add your own information relevant for files or directories in the respective sections after DirectoryQ. Just as a playful example I added FileHash which may slows down things considerably.



          lstlra[dir_] := Dataset[
          <|(* For all files and directories *)
          "FileName" -> FileNameTake[#],
          "Type" -> FileType[#],
          FileDate[#, "Rules"],
          If[
          DirectoryQ[#],
          <|(* Directory only *)
          |>,
          <|(* Files only *)
          "FileSize" -> FileSize[#],
          "MD5-Hash" -> FileHash[#]
          |>
          ]
          |> & /@ FileNames[All, dir]
          ][SortBy["Modification"]]


          enter image description here




          Using File Information



          After the answer by @swish, was very nice to learn about Information applied to File. Here I just change the Head to and Association (using Apply @@) to allow you to put your own stuff. Unfortunately it has too much information, more than you possible need.



          lstlra2[dir_] := Dataset[
          <|
          Association @@ Information[File[#]],
          If[
          DirectoryQ[#],
          <|(* Directory only *)
          |>,
          <|(* Files only *)
          "MD5-Hash" -> FileHash[#]
          |>
          ]
          |> & /@ FileNames[All, dir]
          ][SortBy["LastModificationDate"]]






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 9 hours ago

























          answered 9 hours ago









          rhermansrhermans

          23.3k4 gold badges42 silver badges107 bronze badges




          23.3k4 gold badges42 silver badges107 bronze badges







          • 1




            $begingroup$
            Is there a way to have the final results sorted by date modified (this is also the behavior of ls -tlra I believe).
            $endgroup$
            – George
            9 hours ago










          • $begingroup$
            @George Oh, forgot about that, see last edit. I added [SortBy["Modification"]] and SortBy["LastModificationDate"] depending the function.
            $endgroup$
            – rhermans
            9 hours ago













          • 1




            $begingroup$
            Is there a way to have the final results sorted by date modified (this is also the behavior of ls -tlra I believe).
            $endgroup$
            – George
            9 hours ago










          • $begingroup$
            @George Oh, forgot about that, see last edit. I added [SortBy["Modification"]] and SortBy["LastModificationDate"] depending the function.
            $endgroup$
            – rhermans
            9 hours ago








          1




          1




          $begingroup$
          Is there a way to have the final results sorted by date modified (this is also the behavior of ls -tlra I believe).
          $endgroup$
          – George
          9 hours ago




          $begingroup$
          Is there a way to have the final results sorted by date modified (this is also the behavior of ls -tlra I believe).
          $endgroup$
          – George
          9 hours ago












          $begingroup$
          @George Oh, forgot about that, see last edit. I added [SortBy["Modification"]] and SortBy["LastModificationDate"] depending the function.
          $endgroup$
          – rhermans
          9 hours ago





          $begingroup$
          @George Oh, forgot about that, see last edit. I added [SortBy["Modification"]] and SortBy["LastModificationDate"] depending the function.
          $endgroup$
          – rhermans
          9 hours ago














          7












          $begingroup$

          Try something like that



          props = "CreationDate", "UnixPermissionsString", "ByteCount";
          ls[dir_] :=
          Dataset@FileSystemMap[
          AssociationThread[props -> Information[File@#, props]] &, dir]





          share|improve this answer









          $endgroup$








          • 1




            $begingroup$
            Nice one! (+1) Thanks for introducing me to Information applied to File.
            $endgroup$
            – rhermans
            9 hours ago















          7












          $begingroup$

          Try something like that



          props = "CreationDate", "UnixPermissionsString", "ByteCount";
          ls[dir_] :=
          Dataset@FileSystemMap[
          AssociationThread[props -> Information[File@#, props]] &, dir]





          share|improve this answer









          $endgroup$








          • 1




            $begingroup$
            Nice one! (+1) Thanks for introducing me to Information applied to File.
            $endgroup$
            – rhermans
            9 hours ago













          7












          7








          7





          $begingroup$

          Try something like that



          props = "CreationDate", "UnixPermissionsString", "ByteCount";
          ls[dir_] :=
          Dataset@FileSystemMap[
          AssociationThread[props -> Information[File@#, props]] &, dir]





          share|improve this answer









          $endgroup$



          Try something like that



          props = "CreationDate", "UnixPermissionsString", "ByteCount";
          ls[dir_] :=
          Dataset@FileSystemMap[
          AssociationThread[props -> Information[File@#, props]] &, dir]






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 10 hours ago









          swishswish

          4,38615 silver badges37 bronze badges




          4,38615 silver badges37 bronze badges







          • 1




            $begingroup$
            Nice one! (+1) Thanks for introducing me to Information applied to File.
            $endgroup$
            – rhermans
            9 hours ago












          • 1




            $begingroup$
            Nice one! (+1) Thanks for introducing me to Information applied to File.
            $endgroup$
            – rhermans
            9 hours ago







          1




          1




          $begingroup$
          Nice one! (+1) Thanks for introducing me to Information applied to File.
          $endgroup$
          – rhermans
          9 hours ago




          $begingroup$
          Nice one! (+1) Thanks for introducing me to Information applied to File.
          $endgroup$
          – rhermans
          9 hours ago

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Mathematica Stack Exchange!


          • 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.

          Use MathJax to format equations. MathJax reference.


          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%2fmathematica.stackexchange.com%2fquestions%2f202399%2fmaking-a-dataset-that-emulates-ls-tlra%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

          Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

          Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

          199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單