首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从文件名中删除匹配的regex

从文件名中删除匹配的regex
EN

Unix & Linux用户
提问于 2017-01-28 16:26:07
回答 1查看 502关注 0票数 0

我是电台的所有者,我的个人电脑上有5000多首歌曲。他们的名字是这样的

代码语言:javascript
复制
01. Craig David - Love Yourself (Live from BBC Radio's Live Lounge).mp3
01. The Maccabees - Hello (Live from BBC Radio's Live Lounge).mp3
02. Lukas Graham - 7 Years (Live from BBC Radio's Live Lounge).mp3
02. The Weeknd - Can't Feel My Face (Live from BBC Radio's Live Lounge).mp3
03. Blonde - Work - Pillowtalk - Children (Live from BBC Radio's Live Lounge).mp3
03. Olly Murs - Can't Stop the Feeling - Rock Your Body (Live from BBC Radio's Live Lounge).mp3
04. Coldplay - Adventure of a Lifetime (Live from BBC Radio's Live Lounge).mp3
04. One Direction - Four Five Seconds (Live from BBC Radio's Live Lounge).mp3
05. Jonas Blue - Hotter Than Hell (Live from BBC Radio's Live Lounge).mp3
05. Nick Jonas - Lush Life (Live from BBC Radio's Live Lounge).mp3
06. Fifth Harmony - Ex's & Oh's (Live from BBC Radio's Live Lounge).mp3
06. Jack Garratt - Worry (Live from BBC Radio's Live Lounge).mp3
07. Lower Than Atlantis - On My Mind (Live from BBC Radio's Live Lounge).mp3
07. Usher - Crash (Live from BBC Radio's Live Lounge).mp3
08. Gorgon City - One Dance (Live from BBC Radio's Live Lounge).mp3
08. Grace - You Don't Own Me (Live from BBC Radio's Live Lounge).mp3
09. Dua Lipa - The Hills (Live from BBC Radio's Live Lounge).mp3
09. Mike Posner - In Ibiza (Live from BBC Radio's Live Lounge).mp3
10. DNCE - Hands to Myself (Live from BBC Radio's Live Lounge).mp3
10. Shawn Mendes - Stitches (Live from BBC Radio's Live Lounge).mp3
11. James Bay - Hymn for the Weekend (Live from BBC Radio's Live Lounge).mp3
11. Karen Harding - PILLOWTALK (Live from BBC Radio's Live Lounge).mp3
12. The 1975 - Sorry (Live from BBC Radio's Live Lounge).mp3
12. Tom Odell - The Sound (Live from BBC Radio's Live Lounge).mp3
13. Alessia Cara - Hotline Bling (Live from BBC Radio's Live Lounge).mp3
13. Birdy - Fast Car (Live from BBC Radio's Live Lounge).mp3
14. Jamie Lawson - Wasn't Expecting That (Live from BBC Radio's Live Lounge).mp3
14. M.O - How Will I Know - Perfect Strangers (Live from BBC Radio's Live Lounge).mp3
15. CHVRCHES - This Is What You Came For (Live from BBC Radio's Live Lounge).mp3
15. Kygo - Wildest Dreams (Live from BBC Radio's Live Lounge).mp3
16. Bastille - 7 Days - Final Song (Live from BBC Radio's Live Lounge).mp3
16. Fleur East - Sax (Live from BBC Radio's Live Lounge).mp3
17. Biffy Clyro - (Live from BBC Radio's Live Lounge).mp3
17. Blossoms - In2 (Live from BBC Radio's Live Lounge).mp3
18. Charlie Puth - We Don't Talk Anymore (Live from BBC Radio's Live Lounge).mp3
18. Izzy Bizu - White Tiger (Live from BBC Radio's Live Lounge).mp3
19. Clean Bandit - Work from Home (Live from BBC Radio's Live Lounge).mp3
19. Laura Mvula - New Person, Same Old Mistakes (Live from BBC Radio's Live Lounge).mp3

我想从文件名中删除01.。我发现了几个与我的问题相同的问题,在我的centos 7安装中,没有一个答案对我有效。

代码语言:javascript
复制
/^\d\d. /g

这是我想出来的regex,当我在这里测试它的时候,它是匹配的。

http://regexr.com/

但是,我完全不知道如何用sed实现它,也不知道如何使用重命名查找它。这真的让我很震惊..。

EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2017-01-28 16:37:24

使用zsh

代码语言:javascript
复制
autoload zmv # best in ~/.zshrc
zmv -n '<->. (*)' '$1'

开心时删除-n

<x-y>匹配xy之间的十进制数。<->是任何数字。

票数 2
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/340802

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档