news.volyx.in

Renaming files with mv without typing the name two times (gist.github.com)

669 points by premek · 2368 days ago · 267 comments on HN

Article summary

The article discusses a bash script that allows users to rename files using the mv command without having to type the original file name twice. The script uses bash's built-in read command with the -ei option to allow users to edit the file name. Users can also use other methods such as Ctrl-W Ctrl-Y Ctrl-Y to achieve similar results. The script and alternative methods are useful for renaming files with complex names or for performing batch renames.

Main themes

  • bash scripting
  • file renaming
  • command line techniques
  • readline shortcuts
  • brace expansion
  • file management
  • shell scripting
  • batch processing

What commenters say

  • Using bash's brace expansion can simplify file renaming tasks by allowing users to specify multiple file names at once.
  • The mv command can be used with various options and techniques to achieve efficient file renaming.
  • Some users prefer to use readline's Ctrl-W Ctrl-Y Ctrl-Y to rename files as it is a more general solution that works in many situations.
  • Alternative methods such as using the rename command or other shell scripts can also be effective for renaming files.
  • Some users find the script useful for renaming files with complex names, while others prefer more general solutions that work in a variety of situations.
  • The use of eval and nested braces can allow for more complex file renaming tasks, but may also introduce security risks if not used carefully.
  • Some users recommend using the -b option with the mv command to avoid overwriting existing files.
  • The script and alternative methods can be useful for batch renaming files, but may require additional error checking and handling to ensure correct results.