-
Notifications
You must be signed in to change notification settings - Fork 1
/
fix_channel_name.py
executable file
·43 lines (37 loc) · 1.07 KB
/
fix_channel_name.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 18 16:43:45 2020
@author: adrian
"""
import os
import sys
folderpath=sys.argv[1];
os.chdir(folderpath)
#Find .continuous files
source = '100';
chprefix = 'CH';
Files = [f for f in os.listdir(folderpath) if '.continuous' in f
and '_'+chprefix in f
and source in f]
#Previous name
Files = [f for f in Files if len(f.split('_')) == 3]
#New name
NF=[f.split('_0')[0]+f.split('_0')[1] for f in Files];
#Rename
for (f,nf) in zip(Files,NF):
print(f, nf)
os.rename(f, nf)
#Aux channels
chprefix = 'AUX';
Files = [f for f in os.listdir(folderpath) if '.continuous' in f
and '_'+chprefix in f
and source in f]
#Previous name
Files = [f for f in Files if len(f.split('_')) == 3]
#New name
NF=[f.split('_0')[0]+f.split('_0')[1] for f in Files];
#Rename
for (f,nf) in zip(Files,NF):
print(f, nf)
os.rename(f, nf)