#!/bin/sh if [ "$1" == "-h" ] then echo "Flattens directory structure." echo "Renames dir1/dir2/file.txt to dir1.dir2.file.txt" echo "arguments: [dir]" exit 1 else if [ -n "$1" ] then cd "$1" fi fi find . -type f | while read F do DF=` echo "$F" | sed -e 's@^./@@' -e 's@/@.@g' ` mv -v "$F" "$DF" done