unix命令更改目录名 [英] unix command to change directory name

查看:33
本文介绍了unix命令更改目录名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个简单的问题,但目前我无法找到解决方案..

Hi this is a simple question but the solution eludes me at the moment..

我可以找到我想改名的文件夹名,我知道改名的命令是mv

I can find out the folder name that I want to change the name of, and I know the command to change the name of a folder is mv

所以从当前目录如果我去

so from the current directory if i go

ls ~/relevant.directory.containing.directory.name.i.want.to.change

我得到的目录名称被称为 lorem-ipsum-v1-3

to which i get the name of the directory is called say lorem-ipsum-v1-3

但目录名以后可能会改变,但它是目录中唯一的目录:~/relevant.directory. contains.directory.name.i.want.to.change

but the directory name may change in the future but it is the only directory in the directory: ~/relevant.directory.containing.directory.name.i.want.to.change

如何以编程方式将其更改为特定名称,例如 correct-files

how to i programmatically change it to a specific name like correct-files

我可以通过做类似的事情来正常完成

i can do it normally by just doing something like

 mv lorem-ipsum-v1-3 correct-files

但我想开始自动化,这样我就不需要继续复制和粘贴目录名称....

but I want to start automating this so that I don't need to keep copying and pasting the directory name....

任何帮助将不胜感激...

any help would be appreciated...

推荐答案

类似:

find  . -depth -maxdepth 1 -type d | head -n 1 | xargs -I '{}' mv '{}' correct-files

只要只移动一个目录就可以正常工作.

should work fine as long as only one directory should be moved.

这篇关于unix命令更改目录名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆