]>
zdv2.bktei.com Git - BK-2020-03.git/blob - user/bkdatename
   3 # Date: 2020-05-10T15:27Z 
   4 # Author: Steven Baltakatei Sandoval 
   7 #  [1]: John1024 (2014-08-06). ["linux-shell: renaming files to creation time"](https://stackoverflow.com/a/25153352). Licensed CC BY-SA 4.0. 
   8 #  [2]: Computer Hope (2019-05-04). ["Bash read builtin command"](https://www.computerhope.com/unix/bash/read.htm). 
  10 # Description: Preappends modification time to all files in current 
  15 # Prompt to change filenames for all files in working directory. 
  16 read -p "Append each file's modification date & time to the start of its name in the current working directory? (y/n)" -n 1 -r 
  18 if [[ $REPLY =~ ^
[Yy
]$ 
]] # see [2] 
  20     #Perform renaming operation. 
  24         FILE_MDATE
="$(date -r "$f" +"%Y
%m
%dT
%H
%M
%S
")" # See [1]. 
  25         FILE_NAME_NEW
="$FILE_MDATE"..
"$FILE_NAME" 
  26         # Display new file name 
  27         echo "Renaming $f to:""$FILE_NAME_NEW" 
  28         cp -p .
/"$f" .
/"$FILE_NAME_NEW"