title: Get folder name and rename file name tr Linux bash
body: <p>I have a script that changes the file name. It takes a directory name and added to the file name. By the way, using tr replaces a string:</p>
  
  <p>0004 the name of the directory (this directory is a script)
  - DSC_1234.jpg</p>
  
  <p>result <code>0004_1234.jpg</code></p>
  
  <p>The script works if I am in a particular directory. I wanted to change a name yet in subdirectories</p>
  
  <pre><code>#!/bin/bash
  CURRENT=`pwd`
  BASENAME=`basename $CURRENT`
  echo $BASENAME
  for i in ./*DSC*;do mv -- "$i" "${i//DSC/$BASENAME}";done
  </code></pre>