File tree 2 files changed +34
-0
lines changed
Automation/src/treat_names_here
2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ ## What this script does
2
+ This python script treat the filenames of all of the files in the actual directory where the script is<br >
3
+ Example of usage:
4
+ python treat_names_here.py upper -> gonna rename the files to uppercase it's names
Original file line number Diff line number Diff line change
1
+ import os
2
+ import sys
3
+
4
+ """
5
+ Renames the filenames within the same directory to:
6
+ (1) Changes first letter to uppercase
7
+ (2) Change the filename to uppercase
8
+ (3) Changes the filename to lowercase
9
+ Usage:
10
+ python upper treat_names_here.py
11
+ python lower treat_names_here.py
12
+ python capitalize treat_names_here.py
13
+ """
14
+
15
+ path = os .getcwd ()
16
+ filenames = os .listdir (path )
17
+ opt = str (sys .argv [1 ])
18
+
19
+ for filename in filenames :
20
+ if filename != os .path .basename (__file__ ):
21
+ if opt == 'lower' :
22
+ os .rename (filename , filename .lower ())
23
+
24
+ if opt == 'upper' :
25
+ os .rename (filename , filename .upper ())
26
+
27
+ if opt == 'capitalize' :
28
+ os .rename (filename , filename .capitalize ())
29
+ else :
30
+ print ('omitted actual file' )
You can’t perform that action at this time.
0 commit comments