-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modify files with the same name that have different extensions
- Loading branch information
1 parent
26ea985
commit 075d46f
Showing
1 changed file
with
21 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,21 @@ | ||
# modify files with the same name that have different extensions | ||
import os | ||
|
||
folderPath = 'C:/Users/Folders' | ||
|
||
|
||
def main(): | ||
for filename in os.listdir(folderPath): | ||
# get filename with json ext | ||
if filename.endswith('.json'): | ||
# get filename with png ext | ||
if filename.replace('.json', '.png') in os.listdir(folderPath): | ||
# remove both | ||
print(filename) | ||
os.remove(os.path.join(folderPath, filename)) | ||
os.remove(os.path.join(folderPath, filename.replace('.json', '.png'))) | ||
|
||
|
||
# Driver Code | ||
if __name__ == '__main__': | ||
main() |