X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/91264db571c7957c70a2441b532e32f317b9cf49..46a97d837460ca2122da3e32a963e99b1e76410d:/user/bkdatename?ds=sidebyside diff --git a/user/bkdatename b/user/bkdatename deleted file mode 100755 index ace4e01..0000000 --- a/user/bkdatename +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# Date: 2020-05-10T15:27Z -# Author: Steven Baltakatei Sandoval -# License: GPLv3+ -# Ref./Attrib: -# [1]: John1024 (2014-08-06). ["linux-shell: renaming files to creation time"](https://stackoverflow.com/a/25153352). Licensed CC BY-SA 4.0. -# [2]: Computer Hope (2019-05-04). ["Bash read builtin command"](https://www.computerhope.com/unix/bash/read.htm). - -# Description: Preappends modification time to all files in current -# working directory. - -# Usage: bkdatename - -# Prompt to change filenames for all files in working directory. -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 -echo -if [[ $REPLY =~ ^[Yy]$ ]] # see [2] -then - #Perform renaming operation. - for f in * - do - FILE_NAME="$f" - FILE_MDATE="$(date -r "$f" +"%Y%m%dT%H%M%S")" # See [1]. - FILE_NAME_NEW="$FILE_MDATE".."$FILE_NAME" - # Display new file name - echo "Renaming $f to:""$FILE_NAME_NEW" - cp -p ./"$f" ./"$FILE_NAME_NEW" - rm ./"$f" - done - echo "Done." -fi