Skip to content

Commit

Permalink
Merge pull request #116 from alexmndzdev/Desktop-automation-scripts-#3
Browse files Browse the repository at this point in the history
Added treat_names_here.py
  • Loading branch information
master-fury authored Oct 22, 2018
2 parents e25f894 + 1dc1f03 commit 1e998c7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Automation/src/treat_names_here/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## What this script does
This python script treat the filenames of all of the files in the actual directory where the script is<br>
Example of usage:
python treat_names_here.py upper -> gonna rename the files to uppercase it's names
30 changes: 30 additions & 0 deletions Automation/src/treat_names_here/treat_names_here.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os
import sys

"""
Renames the filenames within the same directory to:
(1) Changes first letter to uppercase
(2) Change the filename to uppercase
(3) Changes the filename to lowercase
Usage:
python upper treat_names_here.py
python lower treat_names_here.py
python capitalize treat_names_here.py
"""

path = os.getcwd()
filenames = os.listdir(path)
opt = str(sys.argv[1])

for filename in filenames:
if filename != os.path.basename(__file__):
if opt == 'lower':
os.rename(filename, filename.lower())

if opt == 'upper':
os.rename(filename, filename.upper())

if opt == 'capitalize':
os.rename(filename, filename.capitalize())
else:
print('omitted actual file')

0 comments on commit 1e998c7

Please sign in to comment.