重命名文件具有相同名称的目录名

问题描述:

我有一个目录结构如下:

I have a directory structure as follows

dir----|
       |
       |--dir1\ some\ thing--result.pdf
       |
       |--dir2\ some\ thing--result.pdf
       |
       |--dir3\ some\ thing--result.pdf
       |

在每个子目录下的文件名是result.pdf。

The file name in each subdirectory is result.pdf.

在哪里为DIR1 DIR2 DIR3有他们的名字空格目录。
什么我无法理解(我写bash脚本)我如何参加这个变量的目录名称重命名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

我想每个文件result.pdf具有相同名称的目录name.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

在目录名中空格创建problems.How过度走到这一步?

blank spaces in directory names are creating problems.How to over come this?

尝试引用的名称:

for i in *; do
  mv "$i/result.pdf" "$i/$i.pdf"
done