파일 이름에서 일치하는 정규식을 제거합니다.

파일 이름에서 일치하는 정규식을 제거합니다.

저는 Cent OS PC에 5000개 이상의 트랙을 보유하고 있는 라디오 방송국 소유자입니다. 그들의 이름은 이렇습니다

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 설치에서는 어떤 답변도 효과가 없었습니다.

/^\d\d. /g

여기에 내가 생각해낸 정규 표현식이 있으며 여기에서 테스트했을 때 일치했습니다.

http://regexr.com/

그러나 나는 그것을 달성하기 위해 sed를 사용하는 방법이나 그것을 찾기 위해 rename을 사용하는 방법을 전혀 모릅니다. 정말 놀랐어요...

답변1

그리고 zsh:

autoload zmv # best in ~/.zshrc
zmv -n '<->. (*)' '$1'

만족스러우면 삭제하세요 -n.

<x-y>x와 사이의 10진수와 일치합니다 y. <->임의의 숫자입니다.

답변2

합계 전용 sed솔루션 sh:

for FILE in *.mp3
do mv "$FILE" "$(echo $FILE | sed -r 's/^[[:digit:]]{2}\. //g')"
done

답변3

파일 이름에서 처음 4자를 제거하려면 다음을 수행하십시오.

for fpath in path/to/songs/*.mp3; do
  fname="${fpath##*/}"
  newname="${fname:4}"
  echo mv "${fpath}" "${fpath%/*}"/"$newname"
done

echo올바른 작업을 수행하고 있다고 확신하면 제거하십시오.

관련 정보