-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fed5c17
commit c5b8a83
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import glob | ||
import os | ||
import re | ||
import sys | ||
|
||
def get_trailing_number(s): | ||
m = re.search(r'\d+$', s) | ||
return int(m.group()) if m else None | ||
|
||
# Function to rename multiple files | ||
def main(mypath, name_stub, len_num): | ||
count = 0 | ||
files = glob.glob(mypath+"*.png") | ||
for current in files: | ||
|
||
number_trailing = re.findall('\d+',current ) | ||
number_trailing = [s.lstrip("0") for s in number_trailing] | ||
print(current, mypath+name_stub+str(number_trailing[0]).zfill(len_num)+"_keypoints") | ||
#print(number_trailing) | ||
os.rename(current, mypath+name_stub+"_"+str(count).zfill(len_num)+".png") | ||
count = count + 1 | ||
|
||
# Driver Code | ||
# Calling main() function, run command ffmpeg -i output_%4d.png output.avi | ||
print(sys.argv) | ||
main(sys.argv[1], "output",4 ) |