更改OS X上目录中所有文件的文件扩展名 [英] Changing file extensions for all files in a directory on OS X

查看:89
本文介绍了更改OS X上目录中所有文件的文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目录中充满了一个具有一个扩展名(在这种情况下为.txt)的文件,我希望将其自动转换为另一个扩展名(.md).

I have a directory full of files with one extension (.txt in this case) that I want to automatically convert to another extension (.md).

是否可以使用一个简单的终端一线工具将该目录中的所有文件转换为其他文件扩展名?

Is there an easy terminal one-liner I can use to convert all of the files in this directory to a different file extension?

还是我需要用正则表达式编写脚本?

Or do I need to write a script with a regular expression?

推荐答案

您可以使用以下内容:

for old in *.txt; do mv $old `basename $old .txt`.md; done

先进行复制!

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

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