[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Merging dirs with (almost) same name



On Tue, 2 May 2006, Magnus Therning wrote:
top/sub1/sub2
top/Sub1/sub2
...

Is there some way (other than mounting a case insensitive file system,
such as FAT) to merge these directories?

I think something like this could work (in bash, anyway), though you'll probably have to do some tweaking:

====================
for dir in $( find top/Sub1 -type d); do
  mkdir -p $( echo ${dir} | tr [:upper:] [:lower:] )
done
for file in $( find top/Sub1 -type f ); do
  cp $file $( echo ${file} | tr [:upper:] [:lower:] )
done
====================

The first loop would create all the non-redundant directories, and the second would copy all the files from those directories over. I *think* that will work, but I've been proven wrong in the past...

HTH,
Jason



Reply to: