bugfixes, features, documentation, examples, new tool
[hband-tools.git] / user-tools / renamemanual
blob93dfea058825b1b5cabc50c24a48efe8aca81e1a
1 #!/bin/bash
3 true <<EOF
4 =pod
6 =head1 NAME
8 renamemanual - Interactive file rename tool
10 =head1 SYNOPSIS
12 renamemanual I<FILE> [I<FILE> [...]]
14 =head1 DESCRIPTION
16 Prompt for the user for new names for the files given in arguments.
17 Won't overwrite existing files,
18 rather keep asking the new name until it can be renamed to (without overwriting an existing file).
19 Skip a file by entering empty name.
21 =head1 SEE ALSO
23 mv(1), rename(1), file-rename(1p) (prename(1)), rename.ul (rename(1)), rename.td(1)
25 =cut
27 EOF
29 if [ $# = 0 ]
30 then
31 pod2text "$0" >&2
32 exit -1
34 if [ "$1" = --help ]
35 then
36 pod2text "$0"
37 exit 0
40 for file in "$@"
42 while true
44 read -e -i "$file" -p "old: $file"$'\n'"new: " newname
45 if [ "$newname" != "$file" -a -n "$newname" ]
46 then
47 if mv -i -v "$file" "$newname"
48 then
49 break
51 else
52 break
54 echo
55 done
56 done