I've have some videos (.mp4) with subtitles files (.SRT) that I need to rename. These files have long names so I can only rename them manually. I've tried Python to rename them, but it fails.
I've tried to rename it with Spacemacs and I did it using Dired SPC f j
to open the folder and renamed the files going line by line: Select the line, go after the number of the video and then deleting till the dot of the extension, I created a simple macro that do this and then ran the macro on all the files in that folder.
I would like to do it with a regexp, so that I can also learn about it.
The folder looks like this in Dired:
total used in directory 477255 available 38636028
drwxrwxrwx 1 User None 28672 02-23 19:04 ..
drwxrwxrwx 1 User None 8192 02-23 19:02 .
-rw-rw-rw- 1 User None 30019832 02-23 13:13 010 Introduction to Global Economics.mp4
-rw-rw-rw- 1 User None 8514 02-23 13:13 010 Introduction to Global Economics-subtitle-en.srt
-rw-rw-rw- 1 User None 263198 02-23 13:13 011 BLS-Unemployment.pdf
-rw-rw-rw- 1 User None 108247504 02-23 13:13 011 The International Monetary Fund GDP.mp4
-rw-rw-rw- 1 User None 28101 02-23 13:14 011 The International Monetary Fund GDP-subtitle-en.srt
-rw-rw-rw- 1 User None 35996597 02-23 13:14 012 Excel Exercise 1 Analyzing IMF GDP Data.mp4
-rw-rw-rw- 1 User None 11454 02-23 12:17 012 Excel Exercise 1 Analyzing IMF GDP Data-subtitle-en.srt
-rw-rw-rw- 1 User None 37911096 02-23 13:15 012 Exercise-1.xlsx
-rw-rw-rw- 1 User None 104361394 02-23 13:15 013 Excel Exercise 1 Part 1 of 3.mp4
-rw-rw-rw- 1 User None 37892 02-23 13:11 013 Excel Exercise 1 Part 1 of 3-subtitle-en.srt
-rw-rw-rw- 1 User None 77650639 02-23 13:13 014 Excel Exercise 1 Part 2 of 3.mp4
-rw-rw-rw- 1 User None 32563 02-23 13:13 014 Excel Exercise 1 Part 2 of 3-subtitle-en.srt
-rw-rw-rw- 1 User None 94068512 02-23 13:14 015 Excel Exercise 1 Part 3 of 3.mp4
-rw-rw-rw- 1 User None 34325 02-23 13:14 015 Excel Exercise 1 Part 3 of 3-subtitle-en.srt
I want to rename the file: 010 Introduction to Global Economics.mp4
to 010.mp4
and 010 Introduction to Global Economics-subtitle-en.srt
to 010.srt
. Also, there are some other files that should not be renamed.
Till now, I tried this \b[0-9]\{3\}\b\( w*\)+.mp4
and it selects the .mp4
files, but how can I then tell it to keep the number of the video?
Edit: All the videos and subtitle files number have always 3 digits, from 001 to 252.
* m
and* r
commands in dired to rename with regular expressions?