User Tools

Site Tools


uppercase_folders_and_files

Source

find . -depth -type d -print0 | xargs -0 rename '$_ = uc $_'
find . -depth -type f -print0 | xargs -0 rename '$_ = uc $_'

This solution is not working fine so the next one is working better

#! /bin/bash
rename_item() {
  if [[ $1 != $2 ]]; then
    mv $i $2;
  fi
}
crawl() {
  for i in *; do
    new=$(echo $i | tr 'a-z' 'A-Z');
    if [[ -f $i ]]; then
      rename_item $i $new
    fi
    if [[ -d $i ]]; then
      rename_item $i $new
      cd $new
      crawl
      cd ..
    fi
  done
}
crawl

uppercase_folders_and_files.txt · Last modified: by 127.0.0.1