daily log 02-13-21

less than 1 minute read


#!/bin/bash
change_filename() {
for d in *; do
  # echo $d
  if [ -d "$d" ]; then
    (cd -- "$d" && change_filename)
  fi
  newdate=$(stat -f %SB -t %Y__%m__%d "$d")
  filepath=$(realpath "$d")
  arrIN=(${filepath//\// })
  filename=${newdate}____${arrIN[1]}
  newname=`echo $filename | sed -e 's/ /_/g'`;
  # echo $newname
  mv "$d" "$newname"
done
}


# find /dir1 -mindepth 2 -type f -exec mv -i '{}' /dir1 ';'

change_filename_old() {
for d in *; do
  # echo $d
  if [ -d "$d" ]; then
    (cd -- "$d" && change_filename)
  fi
  newdate=$(stat -f %SB -t %Y__%m__%d "$d")
  echo $newdate
  # filepath=$(realpath "$d")
  # arrIN=(${filepath//\// })
  # filename=${newdate}____${arrIN[1]}
  # newname=`echo $filename | sed -e 's/ /_/g'`;
  # echo $newname
  # # mv "$d" "$newname"
done
}

recursive_list_6(){
  for d in *; do
  echo $d
  done
}