move files to directory with proper name; print arguments and field in filename

This commit is contained in:
Peter McGoron 2021-08-09 22:14:11 -04:00
parent 48d32924fa
commit 157b0ce047
2 changed files with 22 additions and 3 deletions

View File

@ -13,7 +13,8 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.""" along with this program. If not, see <https://www.gnu.org/licenses/>."""
from argparse import ArgumentParser, BooleanOptionalAction from argparse import ArgumentParser, BooleanOptionalAction
# import dirproc
from .procdir import *
psr = ArgumentParser( psr = ArgumentParser(
description="OPUS Swiss Army Knife 0.1.0", description="OPUS Swiss Army Knife 0.1.0",
@ -22,5 +23,4 @@ psr = ArgumentParser(
psr.add_argument("dir", nargs="+") psr.add_argument("dir", nargs="+")
for i in psr.parse_args().dir: for i in psr.parse_args().dir:
print(i) process(i)
# dirproc.proc(i)

19
osak/procdir.py Normal file
View File

@ -0,0 +1,19 @@
import os
import brukeropusreader as bor
import re
match_opus = re.compile(r"_[0-9]+(\.[0-9]+)?T.0$")
def ifnot(d,v):
if v not in d:
d[v] = {}
def process(s):
for fn in os.listdir(s):
v = re.search(match_opus, fn)
if v is None:
continue
field = v.group()[1:len(v.group())-2]
print(fn)
print(field)
print()