I have a directory structure as follows
dir----|
|
|--dir1\ some\ thing--result.pdf
|
|--dir2\ some\ thing--result.pdf
|
|--dir3\ some\ thing--result.pdf
|
The file name in each subdirectory is result.pdf.
Where as directories dir1 dir2 dir3 have blank spaces in their name. What I am not able to understand (I am writing a bash script) how do I take this directory name in variable and rename result.pdf
I want to rename each of this file result.pdf with same name as directory name.pdf
#!/bin/bash
for i in *;do
cd $i
mv result.pd $i.pdf
cd ..
done
blank spaces in directory names are creating problems.How to over come this?
How about this one-liner -
Try to quote the names: