Skip to content

Commit

Permalink
Create dupeFiles.py
Browse files Browse the repository at this point in the history
modify files with the same name that have different extensions
  • Loading branch information
MarvinZhong authored Apr 15, 2022
1 parent 26ea985 commit 075d46f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions dupeFiles.py
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()

0 comments on commit 075d46f

Please sign in to comment.