linux中文件重命名_如何在Linux中重命名文件?

linux中文件重命名_如何在Linux中重命名文件?linux中文件重命名ThistutorialwillwalkyouthroughthesimplestepstorenameafileinLinux.本教程将引导您完成在Linux中重命名文件的简单步骤。It’sgoingtobeaverysimpleandstraightforwardtutorialevenifyouareabe…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

linux中文件重命名

This tutorial will walk you through the simple steps to rename a file in Linux.

本教程将引导您完成在Linux中重命名文件的简单步骤。

It’s going to be a very simple and straightforward tutorial even if you are a beginner.

即使您是初学者,这也是一个非常简单明了的教程。

开始之前 (Before we begin)

This tutorial was made on a system running Ubuntu 18.04 on a user with sudo privileges. Most of what you will see in this tutorial can be replicated without any modifications on most of the Linux systems out there.

本教程是在具有sudo特权的用户上运行Ubuntu 18.04的系统上制作的。 您可以在本教程中看到的大部分内容都可以复制,而无需对大多数Linux系统进行任何修改。

But in case you are unable to replicate it, you can try another method from the ones mentioned below.

但是,如果您无法复制它,则可以尝试以下提到的方法中的另一种方法。

在Linux中重命名文件的4种方法 (4 Ways to Rename a File in Linux)

It is easy to rename a file in Linux using a GUI file manager or using the command line when you are dealing with a single file. 

在处理单个文件时,使用GUI文件管理器或使用命令行在Linux中重命名文件很容易。

But if you wish to rename multiple files, using the command line is a better approach. In this tutorial, we will discuss 4 different ways in which we can rename a file in Linux.

但是,如果您想重命名多个文件,则使用命令行是一种更好的方法。 在本教程中,我们将讨论在Linux中重命名文件的4种不同方式。

1.使用mv命令 (1. Using the mv command)

The function of the mv command is to move files. However, as a bonus functionality, it can be used to rename a file in Linux. 

mv命令的功能是移动文件。 但是,作为一项附加功能,它可用于在Linux中重命名文件。


mv [OPTIONS] sourcefile destinationfile

While the mv command can be used to move multiple files or directories, we can enter only one file name each for the source and destination. Hence to rename a file OldName.txt to NewName.txt, we use the following command.

虽然mv命令可用于移动多个文件或目录,但我们只能为源和目标分别输入一个文件名。 因此,要将文件OldName.txt重命名为NewName.txt,我们使用以下命令。


mv OldName.txt NewName.txt

The mv command can be used as part of a bash loop or with the find command to rename multiple files at once. 

mv命令可以用作bash循环的一部分,也可以与find命令一起使用,以一次重命名多个文件。

2.使用重命名命令 (2. Using the rename command)

When we wish to rename multiple files at the same time, we can use a utility designed to rename a file in Linux instead of something that can rename files as an unintended functionality.

当我们希望同时重命名多个文件时,可以使用旨在在Linux中重命名文件的实用程序,而不是可以将文件重命名为意外功能的工具。

This brings us to the rename utility. To use the rename command, we install it on our system using apt or whichever package manager your Linux distro has.

这使我们进入了重命名实用程序。 要使用重命名命令,我们使用apt或您的Linux发行版具有的任何软件包管理器将其安装在系统上。


sudo apt install rename

Once the utility is installed, we can now use the rename command through the command-line. 

安装该实用程序后,我们现在可以通过命令行使用重命名命令。


rename [Options] 's/oldname/newname/' *

This command requires basic knowledge of regular expressions. Here, ‘s’ stands for substitute.

此命令需要正则表达式的基本知识。 在这里,“ s”代表替代品。

The remaining expression is self-explanatory. Using * makes the command run for all files whose name contains oldname.

其余的表达式是不言自明的。 使用*可使命令针对名称包含oldname的所有文件运行。

3.使用renameutils (3. Using renameutils)

The renameutils package provides us with a set of commands to rename a file in Linux. With a focus on batch renaming of files, renameutils consists of five commands.

namedutils软件包为我们提供了一组命令,用于在Linux中重命名文件。 着重于文件的重命名,renameutils由五个命令组成。

However, we will focus on two – qmv (quick move) and imv (interactive move) for this tutorial.

但是,在本教程中,我们将重点介绍两个-qmv(快速移动)和imv(交互式移动)。

To install renameutils on our system, we use the following command.

要在我们的系统上安装namedutils,我们使用以下命令。


sudo apt install renameutils

Once the utility is installed, we can now use the qmv and imv commands through the command-line. 

安装该实用程序后,我们现在可以通过命令行使用qmv和imv命令。

Syntax (qmv):

语法(qmv):


qmv directoryname/

This will open a window where the left column displays the original names of the files. Whereas, the right column is for the name which you wish to set for your files. Edit the right column to set the names you wish for your file.

这将打开一个窗口,其中左列显示文件的原始名称。 而右栏是您要为文件设置的名称。 编辑右列以设置所需的文件名。

Syntax (imv):

语法(imv):


imv directoryname/filename

This will display the address of the file. Simply edit the name to rename the file and press enter to save the change.

这将显示文件的地址。 只需编辑名称以重命名文件,然后按Enter键即可保存更改。

Note that imv only allows you to rename one file at a time.

请注意, imv仅允许您一次重命名一个文件。

4.使用GUI文件管理器 (4. Using a GUI file manager)

We can use the bulk rename utility of the Thunar file manager by installing the GUI file manager Thunar with the below command.

通过使用以下命令安装GUI文件管理器Thunar,我们可以使用Thunar文件管理器的批量重命名实用程序。


sudo apt-get install thunar

Now you can launch the bulk rename utility using the following command.

现在,您可以使用以下命令启动批量重命名实用程序。


thunar -B

You can click the + sign to add files. It allows the following criteria for renaming.

您可以单击+号添加文件。 它允许使用以下条件进行重命名。

  • Insert Date or Time

    插入日期或时间

  • Insert or Overwrite

    插入或覆盖

  • Numbering

    编号

  • Remove Characters

    删除字符

  • Search & Replace

    搜索和替换

  • Uppercase / Lowercase

    大写小写

Once you choose the desired criteria, simply click Rename Files to proceed with the operation.

选择所需的条件后,只需单击“重命名文件”即可继续操作。

结语 (Wrapping up)

Linux based systems offer a wide variety of options to rename a file in Linux. One can use any of these to suit their needs and preferences. We hope this tutorial was able to help you understand different ways to rename a file in Linux.

基于Linux的系统提供了多种选项来重命名Linux中的文件。 可以使用其中任何一种来满足他们的需求和喜好。 我们希望本教程能够帮助您了解在Linux中重命名文件的不同方法。

If you have any feedback, queries or corrections, feel free to leave them in the comments below.

如果您有任何反馈,查询或更正,请随时在下面的评论中保留。

翻译自: https://www.journaldev.com/39181/rename-a-file-in-linux

linux中文件重命名

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/195172.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • pycharm怎么配置tensorflow环境_linux系统物理机安装步骤

    pycharm怎么配置tensorflow环境_linux系统物理机安装步骤Tensorflow详细安装步骤及PyCharm配置Tensorflow是谷歌开源的深度学习框架,分为两个版本,GPU和CPU,主要的区别在于计算速度,GPU版本要比CPU计算速度更快,适用于处理大量复杂的数据,但需要计算机配置独立NVIDIA显卡。CPU版本没有显卡要求,安装更简单,合适新手小白和学生党,下面介绍CPU版本Tensorflow的详细安装步骤系统环境:Windows10第一步:安装Anaconda两种方式:直接在Anaconda官方网站下载,但速度很慢;建议第二种,选择镜像网站下载,

    2022年8月28日
    3
  • 大数据的使用方法,主要有哪些?「建议收藏」

    大数据的使用方法,主要有哪些?「建议收藏」我们正处于福雷斯特研究公司所描述的“用户时代”,这个时代中驱动业务决策的不再是公司,而是用户。基于这个原因,深度理解用户的重要性已经远胜以往,因此许多机构开始使用大数据技术来挖掘用户信息。在这个时代,企图收获成功(甚至是求生存)的在线业务必须切实的理解顾客的体验和行为,因此海量数据的收集及挖掘能力成了这些机构的必备手段。当下,有许多机构的分析仍处于数据的收集上,组织能力的缺乏和技术的限制让这些收…

    2022年5月5日
    38
  • Cocos2d-x 集成openinstall(Android)

    Cocos2d-x 集成openinstall(Android)

    2022年3月13日
    90
  • 惯性矩阵计算

    惯性矩阵计算

    2022年6月28日
    23
  • ORACLE优化器

    一ORACLE优化器概述ORACLE优化器是用于生成SQL语句访问数据库时使用的执行计划的。ORACLE优化器通过使用ORACLE搜集的关于数据库对象的统计数据来生成SQL语句的访问计划(使用什么对象)并执行计划(使用何种操作)    二ORACLE优化器的分类 ORACLE优化器分为三类:1)RULE优化器:基于规则的优化器相对比较简单,通过检查数据库的

    2022年4月7日
    42
  • 2019 阿里云峰会·北京站正式启动,互联网出海分论坛报名开启

    2019 阿里云峰会·北京站正式启动,互联网出海分论坛报名开启

    2021年7月2日
    86

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号