Skip to content

Commit 1ce9364

Browse files
committed
#81: added mp3fix
1 parent 41ca159 commit 1ce9364

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

mp3fix/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
```

mp3fix/mp3fix.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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())

0 commit comments

Comments
 (0)