English 中文(简体)
如何用雷管系统重新命名一套档案?
原标题:what is the best way to rename a set of files using a regex?

我拥有一个完整的档案名称目录:“文件1.mp4.mp4. file1.mp4.mp4.file1.mp4.mp4......”。

我愿将其从“文件1.mp4.mp4”到“文件1.mp4”以及它所研究的其他一些工具重新命名。

- 名称:“*.mp4”

问题回答

或者在一旁尝试这种简单的血管?

mv /path/to/file.{mp4.mp4, mp4}

更名。 如果所有档案都在同一目录中,你可以这样做:

rename  s/.mp4.mp4$/.mp4/  *.mp4.mp4

否则,你们可能想要的是:

rename  s/.mp4.mp4$/.mp4/  `find . -name "*.mp4.mp4"`

此外,如果看看你管理<代码>rename,那么就是为了对发言进行反驳,那么:

rename --no-act  s/.mp4.mp4$/.mp4/  *.mp4.mp4

即便是档案名称包含一个空间,例如:

$ touch foo.mp4.mp4
$ touch "bar baz.mp4.mp4"
$ ls
bar baz.mp4.mp4  foo.mp4.mp4
$ rename   s/.mp4.mp4$/.mp4/  *.mp4.mp4
$ ls
bar baz.mp4  foo.mp4
$ 

类似情况:

for file in /path/to/dir/*.mp4; do 
    mv "$file" "${file%.*}"; 
done

http://linux.die.net/man/1/rename”rel=“nofollow”>rename 指挥? 如果是,你可以尝试:

rename .mp4 "" *.mp4.mp4

This will remove the final .mp4 suffix from all files with extension .mp4.mp4 in the current directory.

find . -name  *.mp4.mp4  -exec echo mv {} `dirname {}/`/`basename {} .mp4` ; > mp4.sh && ./mp4.sh && rm mp4.sh




相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签