Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- import subprocess
- import argparse
- import re
- # Parse command line arguments.
- # Run a Bash command and send output to a list seperated by line.
- # Change name function
- def changeName(oldName, newNameBase):
- temp = re.split('([0-9]+)',oldname)
- newName = newNameBase + temp[1] + temp[2]
- subprocess.call(["mv", oldName, newName])
- # Change names of all files matching base
- def changeAllNames(oldNameBase, newNameBase):
- files = runBash("ls")
- for afile in files:
- temp = re.split('([0-9]+)',afile)
- if temp[0] == oldNameBase:
- changeName(afile,newNameBase)
- # Change files with base inputFileName to base outputFileName
- changeAllNames(args.inputFileName,args.outputFileName)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement