重命名文件具有相同名称的目录名 [英] renaming file with same name as directory name
本文介绍了重命名文件具有相同名称的目录名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个目录结构如下:
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
这篇关于重命名文件具有相同名称的目录名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文