How to edit “Name” property in GCI output with regex The 2019 Stack Overflow Developer Survey Results Are InRemote edit with local editor (Linux)Powershell: gci filter with compact outputRegEx expression to replace /randomword/ with <i>randomword</i>?How to modify Text widget's text property in FluidUIEdit existing content with powershellPowershell Custom Properties - Change Property nameHow can you edit powershell_ise.exe.config?How do I get line numbers with PowerShell?How to pad 0 to align the file name middle in the file name with PowerShellSetting logon script property with Powershell

What is this business jet?

What information about me do stores get via my credit card?

Dropping list elements from nested list after evaluation

Is it correct to say the Neural Networks are an alternative way of performing Maximum Likelihood Estimation? if not, why?

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

What do these terms in Caesar's Gallic wars mean?

Kerning for subscripts of sigma?

Deal with toxic manager when you can't quit

Are spiders unable to hurt humans, especially very small spiders?

APIPA and LAN Broadcast Domain

Relationship between Gromov-Witten and Taubes' Gromov invariant

How to display lines in a file like ls displays files in a directory?

writing variables above the numbers in tikz picture

Straighten subgroup lattice

How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?

Does HR tell a hiring manager about salary negotiations?

What is the motivation for a law requiring 2 parties to consent for recording a conversation

How can I define good in a religion that claims no moral authority?

Worn-tile Scrabble

Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?

How much of the clove should I use when using big garlic heads?

Why doesn't shell automatically fix "useless use of cat"?

Can withdrawing asylum be illegal?

Falsification in Math vs Science



How to edit “Name” property in GCI output with regex



The 2019 Stack Overflow Developer Survey Results Are InRemote edit with local editor (Linux)Powershell: gci filter with compact outputRegEx expression to replace /randomword/ with <i>randomword</i>?How to modify Text widget's text property in FluidUIEdit existing content with powershellPowershell Custom Properties - Change Property nameHow can you edit powershell_ise.exe.config?How do I get line numbers with PowerShell?How to pad 0 to align the file name middle in the file name with PowerShellSetting logon script property with Powershell



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








5















# Microsoft Windows [Version 10.0.17134.648] 
# powershell 5.1.17134.48
# parse Notepad++ "backup on save" filenames.
# dir directory. Include index*,avail* where the last write time is less than
# 4 days. Display a parsed Name. Display the Length (size) and the LastWriteTime.
# Can be used as a shortcut: powershell -noexit $time = (Get-Date).AddDays(-4); gci * -include index*,avail* | where $_.LastWriteTime -gt $time | Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Length,LastWriteTime -HideTableHeaders
# Start it in your directory of choice.
$time = (Get-Date).AddDays(-4)
gci * -include index*,avail* | where $_.LastWriteTime -gt $time | Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Length,LastWriteTime -HideTableHeaders


outputs:



available13.html 93130 3/26/2019 8 : 10 : 05 AM
index.html 39386 3/26/2019 8 : 10 : 05 AM


If I use:



$time = (Get-Date).AddDays(-4)
gci * -include index*,avail* | where $_.LastWriteTime -gt $time | format-table -HideTableHeaders Name,Length,LastWriteTime


I get:



available13.html.2019-03-26_081523.bak 93130 3/26/2019 8 : 10 : 05 AM
index.html.2019-03-26_081538.bak 93134 3/26/2019 8 : 15 : 23 AM


Microsoft Windows [Version 10.0.17134.648]

powershell 5.1.17134.48

Parse NPP / Notepad++ / Notepad Plus "backup on save" filenames.

dir directory. Include index*,avail* where the last write time is less than 4 days. Display a parsed Name. Display the Length (size) and the LastWriteTime.

Can be used as a shortcut:
powershell -noexit $time = (Get-Date).AddDays(-4); gci * -include index*,avail* | where $_.LastWriteTime -gt $time | Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Length,LastWriteTime -HideTableHeaders
Start it in your directory of choice.



I use Notepad++ "backup on save" feature to bill my clients for time I work on their website. This script creates a formatted table output with the filenames, size, date and the extent of the time the file was worked on.



See LotPings answer below for information about the name parse.










share|improve this question






























    5















    # Microsoft Windows [Version 10.0.17134.648] 
    # powershell 5.1.17134.48
    # parse Notepad++ "backup on save" filenames.
    # dir directory. Include index*,avail* where the last write time is less than
    # 4 days. Display a parsed Name. Display the Length (size) and the LastWriteTime.
    # Can be used as a shortcut: powershell -noexit $time = (Get-Date).AddDays(-4); gci * -include index*,avail* | where $_.LastWriteTime -gt $time | Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Length,LastWriteTime -HideTableHeaders
    # Start it in your directory of choice.
    $time = (Get-Date).AddDays(-4)
    gci * -include index*,avail* | where $_.LastWriteTime -gt $time | Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Length,LastWriteTime -HideTableHeaders


    outputs:



    available13.html 93130 3/26/2019 8 : 10 : 05 AM
    index.html 39386 3/26/2019 8 : 10 : 05 AM


    If I use:



    $time = (Get-Date).AddDays(-4)
    gci * -include index*,avail* | where $_.LastWriteTime -gt $time | format-table -HideTableHeaders Name,Length,LastWriteTime


    I get:



    available13.html.2019-03-26_081523.bak 93130 3/26/2019 8 : 10 : 05 AM
    index.html.2019-03-26_081538.bak 93134 3/26/2019 8 : 15 : 23 AM


    Microsoft Windows [Version 10.0.17134.648]

    powershell 5.1.17134.48

    Parse NPP / Notepad++ / Notepad Plus "backup on save" filenames.

    dir directory. Include index*,avail* where the last write time is less than 4 days. Display a parsed Name. Display the Length (size) and the LastWriteTime.

    Can be used as a shortcut:
    powershell -noexit $time = (Get-Date).AddDays(-4); gci * -include index*,avail* | where $_.LastWriteTime -gt $time | Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Length,LastWriteTime -HideTableHeaders
    Start it in your directory of choice.



    I use Notepad++ "backup on save" feature to bill my clients for time I work on their website. This script creates a formatted table output with the filenames, size, date and the extent of the time the file was worked on.



    See LotPings answer below for information about the name parse.










    share|improve this question


























      5












      5








      5


      0






      # Microsoft Windows [Version 10.0.17134.648] 
      # powershell 5.1.17134.48
      # parse Notepad++ "backup on save" filenames.
      # dir directory. Include index*,avail* where the last write time is less than
      # 4 days. Display a parsed Name. Display the Length (size) and the LastWriteTime.
      # Can be used as a shortcut: powershell -noexit $time = (Get-Date).AddDays(-4); gci * -include index*,avail* | where $_.LastWriteTime -gt $time | Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Length,LastWriteTime -HideTableHeaders
      # Start it in your directory of choice.
      $time = (Get-Date).AddDays(-4)
      gci * -include index*,avail* | where $_.LastWriteTime -gt $time | Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Length,LastWriteTime -HideTableHeaders


      outputs:



      available13.html 93130 3/26/2019 8 : 10 : 05 AM
      index.html 39386 3/26/2019 8 : 10 : 05 AM


      If I use:



      $time = (Get-Date).AddDays(-4)
      gci * -include index*,avail* | where $_.LastWriteTime -gt $time | format-table -HideTableHeaders Name,Length,LastWriteTime


      I get:



      available13.html.2019-03-26_081523.bak 93130 3/26/2019 8 : 10 : 05 AM
      index.html.2019-03-26_081538.bak 93134 3/26/2019 8 : 15 : 23 AM


      Microsoft Windows [Version 10.0.17134.648]

      powershell 5.1.17134.48

      Parse NPP / Notepad++ / Notepad Plus "backup on save" filenames.

      dir directory. Include index*,avail* where the last write time is less than 4 days. Display a parsed Name. Display the Length (size) and the LastWriteTime.

      Can be used as a shortcut:
      powershell -noexit $time = (Get-Date).AddDays(-4); gci * -include index*,avail* | where $_.LastWriteTime -gt $time | Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Length,LastWriteTime -HideTableHeaders
      Start it in your directory of choice.



      I use Notepad++ "backup on save" feature to bill my clients for time I work on their website. This script creates a formatted table output with the filenames, size, date and the extent of the time the file was worked on.



      See LotPings answer below for information about the name parse.










      share|improve this question
















      # Microsoft Windows [Version 10.0.17134.648] 
      # powershell 5.1.17134.48
      # parse Notepad++ "backup on save" filenames.
      # dir directory. Include index*,avail* where the last write time is less than
      # 4 days. Display a parsed Name. Display the Length (size) and the LastWriteTime.
      # Can be used as a shortcut: powershell -noexit $time = (Get-Date).AddDays(-4); gci * -include index*,avail* | where $_.LastWriteTime -gt $time | Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Length,LastWriteTime -HideTableHeaders
      # Start it in your directory of choice.
      $time = (Get-Date).AddDays(-4)
      gci * -include index*,avail* | where $_.LastWriteTime -gt $time | Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Length,LastWriteTime -HideTableHeaders


      outputs:



      available13.html 93130 3/26/2019 8 : 10 : 05 AM
      index.html 39386 3/26/2019 8 : 10 : 05 AM


      If I use:



      $time = (Get-Date).AddDays(-4)
      gci * -include index*,avail* | where $_.LastWriteTime -gt $time | format-table -HideTableHeaders Name,Length,LastWriteTime


      I get:



      available13.html.2019-03-26_081523.bak 93130 3/26/2019 8 : 10 : 05 AM
      index.html.2019-03-26_081538.bak 93134 3/26/2019 8 : 15 : 23 AM


      Microsoft Windows [Version 10.0.17134.648]

      powershell 5.1.17134.48

      Parse NPP / Notepad++ / Notepad Plus "backup on save" filenames.

      dir directory. Include index*,avail* where the last write time is less than 4 days. Display a parsed Name. Display the Length (size) and the LastWriteTime.

      Can be used as a shortcut:
      powershell -noexit $time = (Get-Date).AddDays(-4); gci * -include index*,avail* | where $_.LastWriteTime -gt $time | Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Length,LastWriteTime -HideTableHeaders
      Start it in your directory of choice.



      I use Notepad++ "backup on save" feature to bill my clients for time I work on their website. This script creates a formatted table output with the filenames, size, date and the extent of the time the file was worked on.



      See LotPings answer below for information about the name parse.







      windows-10 powershell text-editing






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 5 at 15:19







      somebadhat

















      asked Mar 30 at 15:59









      somebadhatsomebadhat

      708




      708




















          2 Answers
          2






          active

          oldest

          votes


















          4














          I'd use a RegEx with zero length lookbehind assertion to remove everything after html from $_.Name



          This can be done with a calculated property either in a Select-Object or also in a Format-*



          Get-ChildItem -File | 
          Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Name -HideTableHeaders


          Sample output:



          available13.html available13.html.2019-03-26_081523.bak
          index.html index.html.2019-03-26_081538.bak





          share|improve this answer






























            4














            You can add a new property with Add-Member like this



            $time = (Get-Date).AddDays(-4)
            $files = gci * -include index*,avail* | where $_.LastWriteTime -gt $time
            foreach ($f in $files) Add-Member noteproperty newName -Value `
            $f.Name.Substring(0, $f.Name.Length - ".yyyy-mm-dd_iiiiii.bak".Length)

            $files | Format-Table -HideTableHeaders newName,Length,LastWriteTime


            Note that the above snippet assumes that your names always end with .yyyy-mm-dd_iiiiii.bak. If they have some other format then you must include that information in the question, and you may need to use other string methods like replace, substring... to remove the unnecessary part






            share|improve this answer

























            • @LotPings I choose LotPings answer because it would have been the answer if I had asked a better question. Thanks for taking the time. Your code works.

              – somebadhat
              Apr 4 at 16:49











            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%2f1419414%2fhow-to-edit-name-property-in-gci-output-with-regex%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









            4














            I'd use a RegEx with zero length lookbehind assertion to remove everything after html from $_.Name



            This can be done with a calculated property either in a Select-Object or also in a Format-*



            Get-ChildItem -File | 
            Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Name -HideTableHeaders


            Sample output:



            available13.html available13.html.2019-03-26_081523.bak
            index.html index.html.2019-03-26_081538.bak





            share|improve this answer



























              4














              I'd use a RegEx with zero length lookbehind assertion to remove everything after html from $_.Name



              This can be done with a calculated property either in a Select-Object or also in a Format-*



              Get-ChildItem -File | 
              Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Name -HideTableHeaders


              Sample output:



              available13.html available13.html.2019-03-26_081523.bak
              index.html index.html.2019-03-26_081538.bak





              share|improve this answer

























                4












                4








                4







                I'd use a RegEx with zero length lookbehind assertion to remove everything after html from $_.Name



                This can be done with a calculated property either in a Select-Object or also in a Format-*



                Get-ChildItem -File | 
                Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Name -HideTableHeaders


                Sample output:



                available13.html available13.html.2019-03-26_081523.bak
                index.html index.html.2019-03-26_081538.bak





                share|improve this answer













                I'd use a RegEx with zero length lookbehind assertion to remove everything after html from $_.Name



                This can be done with a calculated property either in a Select-Object or also in a Format-*



                Get-ChildItem -File | 
                Format-Table @n='foo';e=$_.Name -replace '(?<=^.*.html).*$',Name -HideTableHeaders


                Sample output:



                available13.html available13.html.2019-03-26_081523.bak
                index.html index.html.2019-03-26_081538.bak






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 30 at 16:35









                LotPingsLotPings

                5,3061923




                5,3061923























                    4














                    You can add a new property with Add-Member like this



                    $time = (Get-Date).AddDays(-4)
                    $files = gci * -include index*,avail* | where $_.LastWriteTime -gt $time
                    foreach ($f in $files) Add-Member noteproperty newName -Value `
                    $f.Name.Substring(0, $f.Name.Length - ".yyyy-mm-dd_iiiiii.bak".Length)

                    $files | Format-Table -HideTableHeaders newName,Length,LastWriteTime


                    Note that the above snippet assumes that your names always end with .yyyy-mm-dd_iiiiii.bak. If they have some other format then you must include that information in the question, and you may need to use other string methods like replace, substring... to remove the unnecessary part






                    share|improve this answer

























                    • @LotPings I choose LotPings answer because it would have been the answer if I had asked a better question. Thanks for taking the time. Your code works.

                      – somebadhat
                      Apr 4 at 16:49















                    4














                    You can add a new property with Add-Member like this



                    $time = (Get-Date).AddDays(-4)
                    $files = gci * -include index*,avail* | where $_.LastWriteTime -gt $time
                    foreach ($f in $files) Add-Member noteproperty newName -Value `
                    $f.Name.Substring(0, $f.Name.Length - ".yyyy-mm-dd_iiiiii.bak".Length)

                    $files | Format-Table -HideTableHeaders newName,Length,LastWriteTime


                    Note that the above snippet assumes that your names always end with .yyyy-mm-dd_iiiiii.bak. If they have some other format then you must include that information in the question, and you may need to use other string methods like replace, substring... to remove the unnecessary part






                    share|improve this answer

























                    • @LotPings I choose LotPings answer because it would have been the answer if I had asked a better question. Thanks for taking the time. Your code works.

                      – somebadhat
                      Apr 4 at 16:49













                    4












                    4








                    4







                    You can add a new property with Add-Member like this



                    $time = (Get-Date).AddDays(-4)
                    $files = gci * -include index*,avail* | where $_.LastWriteTime -gt $time
                    foreach ($f in $files) Add-Member noteproperty newName -Value `
                    $f.Name.Substring(0, $f.Name.Length - ".yyyy-mm-dd_iiiiii.bak".Length)

                    $files | Format-Table -HideTableHeaders newName,Length,LastWriteTime


                    Note that the above snippet assumes that your names always end with .yyyy-mm-dd_iiiiii.bak. If they have some other format then you must include that information in the question, and you may need to use other string methods like replace, substring... to remove the unnecessary part






                    share|improve this answer















                    You can add a new property with Add-Member like this



                    $time = (Get-Date).AddDays(-4)
                    $files = gci * -include index*,avail* | where $_.LastWriteTime -gt $time
                    foreach ($f in $files) Add-Member noteproperty newName -Value `
                    $f.Name.Substring(0, $f.Name.Length - ".yyyy-mm-dd_iiiiii.bak".Length)

                    $files | Format-Table -HideTableHeaders newName,Length,LastWriteTime


                    Note that the above snippet assumes that your names always end with .yyyy-mm-dd_iiiiii.bak. If they have some other format then you must include that information in the question, and you may need to use other string methods like replace, substring... to remove the unnecessary part







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Mar 30 at 16:47

























                    answered Mar 30 at 16:40









                    phuclvphuclv

                    10.7k64297




                    10.7k64297












                    • @LotPings I choose LotPings answer because it would have been the answer if I had asked a better question. Thanks for taking the time. Your code works.

                      – somebadhat
                      Apr 4 at 16:49

















                    • @LotPings I choose LotPings answer because it would have been the answer if I had asked a better question. Thanks for taking the time. Your code works.

                      – somebadhat
                      Apr 4 at 16:49
















                    @LotPings I choose LotPings answer because it would have been the answer if I had asked a better question. Thanks for taking the time. Your code works.

                    – somebadhat
                    Apr 4 at 16:49





                    @LotPings I choose LotPings answer because it would have been the answer if I had asked a better question. Thanks for taking the time. Your code works.

                    – somebadhat
                    Apr 4 at 16:49

















                    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%2f1419414%2fhow-to-edit-name-property-in-gci-output-with-regex%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

                    Triangular numbers and gcdProving sum of a set is $0 pmod n$ if $n$ is odd, or $fracn2 pmod n$ if $n$ is even?Is greatest common divisor of two numbers really their smallest linear combination?GCD, LCM RelationshipProve a set of nonnegative integers with greatest common divisor 1 and closed under addition has all but finite many nonnegative integers.all pairs of a and b in an equation containing gcdTriangular Numbers Modulo $k$ - Hit All Values?Understanding the Existence and Uniqueness of the GCDGCD and LCM with logical symbolsThe greatest common divisor of two positive integers less than 100 is equal to 3. Their least common multiple is twelve times one of the integers.Suppose that for all integers $x$, $x|a$ and $x|b$ if and only if $x|c$. Then $c = gcd(a,b)$Which is the gcd of 2 numbers which are multiplied and the result is 600000?

                    Ingelân Ynhâld Etymology | Geografy | Skiednis | Polityk en bestjoer | Ekonomy | Demografy | Kultuer | Klimaat | Sjoch ek | Keppelings om utens | Boarnen, noaten en referinsjes Navigaasjemenuwww.gov.ukOffisjele webside fan it regear fan it Feriene KeninkrykOffisjele webside fan it Britske FerkearsburoNederlânsktalige ynformaasje fan it Britske FerkearsburoOffisjele webside fan English Heritage, de organisaasje dy't him ynset foar it behâld fan it Ingelske kultuergoedYnwennertallen fan alle Britske stêden út 'e folkstelling fan 2011Notes en References, op dizze sideEngland

                    Հադիս Բովանդակություն Անվանում և նշանակություն | Դասակարգում | Աղբյուրներ | Նավարկման ցանկ