How to change the names of the photovoltaic files



  • Good afternoon. I need to remove the souffix on behalf of the file and add the prefix to the start of the file. You need to change in a way. I tried to do this:

     for f in $(find /folder/ . -name "*_file._small.mov*");
     do mv $f $(echo $f | sed '/._small/s/._small//g');
     done
    

    but it doesn't work.

    87349_file._small.mov and turn into small_87349_file

    Thank you.



  • similar questions:

    • https://ru.stackoverflow.com/q/451330/178576
    • https://ru.stackoverflow.com/q/436348/178576

    A ready solution may look, for example:

    find /folder/ -type f -name \*_file._small.mov\* | while read f; do
      d=$(dirname $f)
      n=$(basename $f)
      (cd $d; prename -n 's/\._small\.mov//;s/^/small_/' $n)
    done
    

    Look at the parameter. -n programme prename - He will not rename the files, but will only be given a report on possible actions (to rename this parameter should be removed).

    87348_file._small.mov renamed as small_87348_file
    87349_file._small.mov renamed as small_87349_file
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2