Skip to content
Browse files

Mass renamer with no error checking. Works for file extensions of any…

… length
  • Loading branch information...
1 parent 031dbce commit 0cbe8b8f09414c125dfb8a917e34bc4d105c5310 @parthgajaria committed
Showing with 13 additions and 0 deletions.
  1. +13 −0 MassRenamer.py
View
13 MassRenamer.py
@@ -0,0 +1,13 @@
+import os
+
+print "This script will rename files from one file extension to another"
+from_ext = raw_input("Enter the file extension you wish to convert from (ie. jpg): ")
+to_ext = raw_input("Enter the file extension you wish to convert to (ie. gif): ")
+root_dir = raw_input("Enter the absolute path of the directory which contains the files (ie. D:\Comics): ")
+from_ext_len = len(from_ext)
+#Look through directory tree
+for root, subFolders, files in os.walk(root_dir):
+ for file in files:
+ if file[-(from_ext_len + 1):] == "." + from_ext:
+ os.rename(os.path.join(root,file), os.path.join(root,file[:-(from_ext_len + 1)] + "." + to_ext))
+ print "Conversion Successful"

0 comments on commit 0cbe8b8

Please sign in to comment.
Something went wrong with that request. Please try again.