File tree 2 files changed +38
-0
lines changed
2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ ### Author
2
+ Riccardo Tasso
3
+
4
+ #### Description
5
+
6
+ mp3fix iterates through all files with the .mp3 extension within the current directory.
7
+
8
+ If the file name begins with a one-digit number that is not preceded by zero, rename the file to meet this standard.
9
+
10
+ #### How to use
11
+
12
+ ```
13
+ python2 mp3fix.py mp3folder/
14
+ ```
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import sys
5
+ import re
6
+ import os
7
+
8
+ p = re .compile (r'^\d\D.*?[.]mp3$' )
9
+
10
+ def main ():
11
+ path = sys .argv [1 ]
12
+
13
+ for file in os .listdir (path ):
14
+ print file
15
+ m = p .match (file )
16
+ if m :
17
+ old_file = os .path .join (path , file )
18
+ new_file = os .path .join (path , "0" + file )
19
+ #raw_input(old_file + " " + new_file)
20
+ os .rename (old_file , new_file )
21
+
22
+
23
+ if __name__ == "__main__" :
24
+ sys .exit (main ())
You can’t perform that action at this time.
0 commit comments