Renaming files in command line can be rather cumbersome when using mv. The conceptual problem with mv is that you have to retype the complete target file path, which includes the path to the containing directory and the all the unchanged parts of the file name. Of course, auto-completion is a very helpful feature in these situations, but still the whole path has to be provided and further, the unchanged suffix must always be entered manually. For this purpose, I wrote a very basic script which avoids retyping the path and allows for in-place modification of the file name to be changed.

[[ $# -eq 0 ]] && echo "No argument given." && exit 1
for old_path in "$@"; do
  [[ ! -e "$old_path" ]] && echo "Path does not exist: $old_path" && continue
  echo "Old path: $old_path"
  dir=`dirname "$old_path"`
  read -e -i "`basename "$old_path"`" -p "New path: $dir/" new_name
  [[ ! $? -eq 0 ]] && echo "Reading new path failed. Aborting." && exit 2
  [[ "$new_path" == "$old_path" ]] && echo "Path not changed." && continue
  mv "$old_path" "$new_path"


Note that also relative move operations are possible. For instance, by prepending ../ to the file name you can move the target file to the parent directory. Also, using the HOME (or in German Pos1) key can be very convenient to achieve this or, in general, to get to the front of the file name.