【问题标题】:Rename file with same name present in sub folders to include sub folder name重命名子文件夹中存在的同名文件以包含子文件夹名称
【发布时间】:2016-02-05 15:35:28
【问题描述】:

有多个文件夹 ..folder1、folder2..foldern,每个文件夹都有很多文件,但每个文件夹中都有一个名为 sample.txt 的文件。

有没有办法重命名所有 sample.txt 以便将它们重命名为父文件夹的名称 例如。文件夹 1/sample.txt -> 文件夹 1.txt 文件夹 2/sample.txt ->文件夹 2.txt .. 文件夹n/sample.txt -> 文件夹n.txt

【问题讨论】:

  • 看看find 实用程序,您应该可以将其exec 功能与sed 处理器结合起来。

标签: linux unix rename mv


【解决方案1】:

FILES=$PWD/Feline_combined/*/

对于 $FILES 中的 f

cd $f

测试=${PWD##*/}

回声 $test

cp fastqjoin.join.fastq ~/Desktop/Shared_Folder/Project_VRB/shell/$test.fastq

完成

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-11
    • 2021-07-15
    • 2018-08-21
    • 2014-03-05
    • 1970-01-01
    • 1970-01-01
    • 2013-04-14
    相关资源
    最近更新 更多