-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from alexmndzdev/Desktop-automation-scripts-#3
Added treat_names_here.py
- Loading branch information
Showing
2 changed files
with
34 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,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 |
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,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') |