在Unix中重命名多个文件 [英] Renaming Multiple Files in Unix

查看:93
本文介绍了在Unix中重命名多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文件格式如下

EnvName.Fullbkp.schema_10022012_0630_Part1.expd
EnvName.Fullbkp.schema_10022012_0630_Part2.expd
EnvName.Fullbkp.schema_10022012_0630_Part3.expd
EnvName.Fullbkp.schema_10022012_0630_Part4.expd

我想用下面的文件重命名

I want to rename this with below files

EnvName.Fullbkp.schema_22052013_1000_Part1.expd
EnvName.Fullbkp.schema_22052013_1000_Part2.expd
EnvName.Fullbkp.schema_22052013_1000_Part3.expd
EnvName.Fullbkp.schema_22052013_1000_Part4.expd

这意味着我只想用22052013_1000重命名10022012_0630用于重命名singe go中所有文件的命令和循环是什么

It means I just want to rename the 10022012_0630 with 22052013_1000 what would be the commands and loop to be used to rename all the files in singe go

推荐答案

一种非常有效的方法,尤其是在处理成千上万个文件的情况下,是使用bash替换字符串并查找.这样可以避免许多无用的fork/execve,并将进程计数降至最低:

A very effecient method, especially if you're dealing with thousands of files is to use bash for the string replacements and find for the lookup. This will avoid many useless forks/execve's and keep the process count down to a minimum:

for F in $(find /your/path/ -type f -name '*10022012_0630*'); do
  mv $F ${F/10022012_0630/22052013_1000};
done

这篇关于在Unix中重命名多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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