]>
git.scottworley.com Git - picsort/blob - rename-to-date
10 shift "$((OPTIND - 1))"
13 if [[ ! -e "$f" ]];then
14 echo "Input file \"$f\" does not exist." >&2
18 new_name
="$(find "$f" -printf "%TY-%Tm-%Td %TT %TZ").$extension"
19 while [[ -e "$new_name" ]];do
20 if $skip_duplicates;then
21 if [[ "$(find "$f" -printf '%i')" == "$(find "$new_name" -printf '%i')" ]];then
22 echo "Skipping $f: it is already $new_name (same inode)"
24 if cmp "$f" "$new_name";then
25 echo "Skipping $f: it is already $new_name"
31 if (( ${#t} != 10 ));then
32 echo "Expected $t (from $new_name) to be 10 characters" >&2
35 t
=$(printf "%010d" $(( $(sed 's/^0*//' <<< "$t") + 1 )) )
36 new_name
="${fields[0]} ${fields[1]%.*}.$t ${fields[2]}"
38 $mv_command -vi "$f" "$new_name"