-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathrenamer.py
31 lines (26 loc) · 945 Bytes
/
renamer.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
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
''' Imports '''
import os
import sys
import operator
import argparse
''' Initialize argparse flags '''
parser = argparse.ArgumentParser("Data Renamer")
parser.add_argument("--buffer", "-b", dest="buffer", required=True, type=int, help="increment labels and video numbers by this amount")
args = parser.parse_args()
buffer = args,buffer
data_file = "data"
nums = []
files = []
for data in os.listdir("%s/video/videos" % data_file):
file_num , _ = data.split('.')
file_num = int(file_num)
nums.append(file_num)
files.append(data)
for i in range(len(nums)):
idx, num = max(enumerate(nums), key=operator.itemgetter(1))
fn = files[idx]
nums.pop(idx)
files.pop(idx)
os.rename(fn, "%s/video/videos/%d.npz" % (data_file, num + buffer))
os.rename("%s/video/labels/%d.txt" % (data_file, num), "%s/video/labels/%d.txt" % (data_file, num + buffer))