Renaming files with vidir (moreutils) and regex substitution The 2019 Stack Overflow Developer Survey Results Are InCan tr work with regex?find files containing space and specific string in their filename and rename itcomparing the numbers and collecting details and providing output to new fileBash script variable with if else statement but with loopSelecting non-existent files with wildcard/regexRenaming and rearranging multiple filenames without renamePerl rename hangs when renaming files with regular expressionProblem with “rename” using regex (Linux)How to query all lines in a file that are NOT equal or suffix of any name in another filedeleting files older than a specific day and excluding the direct files under folder

Looking for Correct Greek Translation for Heraclitus

Is flight data recorder erased after every flight?

One word riddle: Vowel in the middle

How to type this arrow in math mode?

What did it mean to "align" a radio?

Should I use my personal e-mail address, or my workplace one, when registering to external websites for work purposes?

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

How come people say “Would of”?

Aging parents with no investments

Time travel alters history but people keep saying nothing's changed

Why do we hear so much about the Trump administration deciding to impose and then remove tariffs?

Why was M87 targetted for the Event Horizon Telescope instead of Sagittarius A*?

Delete all lines which don't have n characters before delimiter

What is the most effective way of iterating a std::vector and why?

What tool would a Roman-age civilization have for the breaking of silver and other metals into dust?

Is there a symbol for a right arrow with a square in the middle?

A poker game description that does not feel gimmicky

Does the shape of a die affect the probability of a number being rolled?

Identify boardgame from Big movie

Why isn't the circumferential light around the M87 black hole's event horizon symmetric?

How technical should a Scrum Master be to effectively remove impediments?

Can you compress metal and what would be the consequences?

Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?

Output the Arecibo Message



Renaming files with vidir (moreutils) and regex substitution



The 2019 Stack Overflow Developer Survey Results Are InCan tr work with regex?find files containing space and specific string in their filename and rename itcomparing the numbers and collecting details and providing output to new fileBash script variable with if else statement but with loopSelecting non-existent files with wildcard/regexRenaming and rearranging multiple filenames without renamePerl rename hangs when renaming files with regular expressionProblem with “rename” using regex (Linux)How to query all lines in a file that are NOT equal or suffix of any name in another filedeleting files older than a specific day and excluding the direct files under folder



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








2















I'm trying to use vidir from the moreutils package and I have the following issue:
When I load the files I want to rename with vidir like this:



$ vidir


or like this:



$ find -type f | vidir --verbose -


vidir displays a number, a tab, and the full path of the files like this:



1 ./file1
2 ./file2
3 ./file3


or if it isn't the current folder like this:



1 ./folder/subfolder1/file1
2 ./folder/subfolder1/file2
3 ./folder/subfolder1/file3


Now, I see some advantages in this like the ability to swap file names by swaping the numbers or editing folder names but I just want to rename the files in the same folder and maybe delete some files. My issue is when I use regex to rename the filenames everything could be affected,namely the numbers, the slashes, the dots and the tabs. I tried to remove them at start make my modifications and then rebuild them but vidir complains when I save the file and close the editor.



So how could circumvent this issue? Am I missing something?



EDIT:
I tried again to remove the vidir prefix before I start my modifications and add it back when I'm finished and it seems to be working. So in Vim:



: % s/d*t.//


to remove the prefix



and with:



:% s/^/t./
:'<,'>s/^/=(line('.')-line("'<")+1)/


to add the vidir prefix back.



The last line for adding the numbers I found here:



https://stackoverflow.com/questions/252766/add-line-numbers-to-source-code-in-vim



Now I want to add these lines in functions and I'm stuck at this line:



 :'<,'>s/^/=(line('.')-line("'<")+1)/


there seems to be an issue with the quotes and it doesn't work any more. When I put it within quotes I get an error. Could someone tell me what's going on?
This is the function I have:



" Add vidir prefix
function! AddVidirPrefix()
execute '% s/^/t./'
"execute 'normal! ggVG'
execute '<,'>s/^/=(line('.')-line("'<")+1)/
endfunction









share|improve this question









New contributor




coverflower is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    2















    I'm trying to use vidir from the moreutils package and I have the following issue:
    When I load the files I want to rename with vidir like this:



    $ vidir


    or like this:



    $ find -type f | vidir --verbose -


    vidir displays a number, a tab, and the full path of the files like this:



    1 ./file1
    2 ./file2
    3 ./file3


    or if it isn't the current folder like this:



    1 ./folder/subfolder1/file1
    2 ./folder/subfolder1/file2
    3 ./folder/subfolder1/file3


    Now, I see some advantages in this like the ability to swap file names by swaping the numbers or editing folder names but I just want to rename the files in the same folder and maybe delete some files. My issue is when I use regex to rename the filenames everything could be affected,namely the numbers, the slashes, the dots and the tabs. I tried to remove them at start make my modifications and then rebuild them but vidir complains when I save the file and close the editor.



    So how could circumvent this issue? Am I missing something?



    EDIT:
    I tried again to remove the vidir prefix before I start my modifications and add it back when I'm finished and it seems to be working. So in Vim:



    : % s/d*t.//


    to remove the prefix



    and with:



    :% s/^/t./
    :'<,'>s/^/=(line('.')-line("'<")+1)/


    to add the vidir prefix back.



    The last line for adding the numbers I found here:



    https://stackoverflow.com/questions/252766/add-line-numbers-to-source-code-in-vim



    Now I want to add these lines in functions and I'm stuck at this line:



     :'<,'>s/^/=(line('.')-line("'<")+1)/


    there seems to be an issue with the quotes and it doesn't work any more. When I put it within quotes I get an error. Could someone tell me what's going on?
    This is the function I have:



    " Add vidir prefix
    function! AddVidirPrefix()
    execute '% s/^/t./'
    "execute 'normal! ggVG'
    execute '<,'>s/^/=(line('.')-line("'<")+1)/
    endfunction









    share|improve this question









    New contributor




    coverflower is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      2












      2








      2








      I'm trying to use vidir from the moreutils package and I have the following issue:
      When I load the files I want to rename with vidir like this:



      $ vidir


      or like this:



      $ find -type f | vidir --verbose -


      vidir displays a number, a tab, and the full path of the files like this:



      1 ./file1
      2 ./file2
      3 ./file3


      or if it isn't the current folder like this:



      1 ./folder/subfolder1/file1
      2 ./folder/subfolder1/file2
      3 ./folder/subfolder1/file3


      Now, I see some advantages in this like the ability to swap file names by swaping the numbers or editing folder names but I just want to rename the files in the same folder and maybe delete some files. My issue is when I use regex to rename the filenames everything could be affected,namely the numbers, the slashes, the dots and the tabs. I tried to remove them at start make my modifications and then rebuild them but vidir complains when I save the file and close the editor.



      So how could circumvent this issue? Am I missing something?



      EDIT:
      I tried again to remove the vidir prefix before I start my modifications and add it back when I'm finished and it seems to be working. So in Vim:



      : % s/d*t.//


      to remove the prefix



      and with:



      :% s/^/t./
      :'<,'>s/^/=(line('.')-line("'<")+1)/


      to add the vidir prefix back.



      The last line for adding the numbers I found here:



      https://stackoverflow.com/questions/252766/add-line-numbers-to-source-code-in-vim



      Now I want to add these lines in functions and I'm stuck at this line:



       :'<,'>s/^/=(line('.')-line("'<")+1)/


      there seems to be an issue with the quotes and it doesn't work any more. When I put it within quotes I get an error. Could someone tell me what's going on?
      This is the function I have:



      " Add vidir prefix
      function! AddVidirPrefix()
      execute '% s/^/t./'
      "execute 'normal! ggVG'
      execute '<,'>s/^/=(line('.')-line("'<")+1)/
      endfunction









      share|improve this question









      New contributor




      coverflower is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I'm trying to use vidir from the moreutils package and I have the following issue:
      When I load the files I want to rename with vidir like this:



      $ vidir


      or like this:



      $ find -type f | vidir --verbose -


      vidir displays a number, a tab, and the full path of the files like this:



      1 ./file1
      2 ./file2
      3 ./file3


      or if it isn't the current folder like this:



      1 ./folder/subfolder1/file1
      2 ./folder/subfolder1/file2
      3 ./folder/subfolder1/file3


      Now, I see some advantages in this like the ability to swap file names by swaping the numbers or editing folder names but I just want to rename the files in the same folder and maybe delete some files. My issue is when I use regex to rename the filenames everything could be affected,namely the numbers, the slashes, the dots and the tabs. I tried to remove them at start make my modifications and then rebuild them but vidir complains when I save the file and close the editor.



      So how could circumvent this issue? Am I missing something?



      EDIT:
      I tried again to remove the vidir prefix before I start my modifications and add it back when I'm finished and it seems to be working. So in Vim:



      : % s/d*t.//


      to remove the prefix



      and with:



      :% s/^/t./
      :'<,'>s/^/=(line('.')-line("'<")+1)/


      to add the vidir prefix back.



      The last line for adding the numbers I found here:



      https://stackoverflow.com/questions/252766/add-line-numbers-to-source-code-in-vim



      Now I want to add these lines in functions and I'm stuck at this line:



       :'<,'>s/^/=(line('.')-line("'<")+1)/


      there seems to be an issue with the quotes and it doesn't work any more. When I put it within quotes I get an error. Could someone tell me what's going on?
      This is the function I have:



      " Add vidir prefix
      function! AddVidirPrefix()
      execute '% s/^/t./'
      "execute 'normal! ggVG'
      execute '<,'>s/^/=(line('.')-line("'<")+1)/
      endfunction






      regular-expression






      share|improve this question









      New contributor




      coverflower is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      coverflower is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited yesterday







      coverflower













      New contributor




      coverflower is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 days ago









      coverflowercoverflower

      112




      112




      New contributor




      coverflower is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      coverflower is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      coverflower is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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
          );



          );






          coverflower is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511352%2frenaming-files-with-vidir-moreutils-and-regex-substitution%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          coverflower is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          coverflower is a new contributor. Be nice, and check out our Code of Conduct.












          coverflower is a new contributor. Be nice, and check out our Code of Conduct.











          coverflower is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Unix & Linux 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.

          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%2funix.stackexchange.com%2fquestions%2f511352%2frenaming-files-with-vidir-moreutils-and-regex-substitution%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







          -regular-expression

          Popular posts from this blog

          Creating 100m^2 grid automatically using QGIS?Creating grid constrained within polygon in QGIS?Createing polygon layer from point data using QGIS?Creating vector grid using QGIS?Creating grid polygons from coordinates using R or PythonCreating grid from spatio temporal point data?Creating fields in attributes table using other layers using QGISCreate .shp vector grid in QGISQGIS Creating 4km point grid within polygonsCreate a vector grid over a raster layerVector Grid Creates just one grid

          Nikolai Prilezhaev Bibliography References External links Navigation menuEarly Russian Organic Chemists and Their Legacy092774english translationRussian Biography

          How to link a C library to an Assembly library on Mac with clangHow do you set, clear, and toggle a single bit?Find (and kill) process locking port 3000 on MacWho is listening on a given TCP port on Mac OS X?How to start PostgreSQL server on Mac OS X?Compile assembler in nasm on mac osHow do I install pip on macOS or OS X?AFNetworking 2.0 “_NSURLSessionTransferSizeUnknown” linking error on Mac OS X 10.8C++ code for testing the Collatz conjecture faster than hand-written assembly - why?How to link a NASM code and GCC in Mac OS X?How to run x86 .asm on macOS Sierra