-
-
Save idolpx/eadd12cb15daa61d9253f325a0381778 to your computer and use it in GitHub Desktop.
Revisions
-
idolpx revised this gist
May 29, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import os, re, py7zr #with py7zr.SevenZipFile('sample.7z', mode='r') as z: # z.extractall() #def extractCB(p1, p2): # print( '[' + p1 + '] [' + p2 + ']' ) -
idolpx revised this gist
Nov 30, 2023 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,9 @@ # # Move files to directories 0-z based on 1st char of filename # https://gist.github.com/idolpx/eadd12cb15daa61d9253f325a0381778 # # Jaime Idolpx # import os, re, py7zr -
idolpx created this gist
Nov 30, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ #!/usr/local/bin/python3 # # Move files to directories 0-z based on 1st char of filename # import os, re, py7zr #with py7zr.SevenZipFile('sample.7z', mode='r') as z: # z.extractall() (END) #def extractCB(p1, p2): # print( '[' + p1 + '] [' + p2 + ']' ) # Getting the current work directory (cwd) src_dir = os.getcwd() + os.sep dest_dir = os.getcwd() + os.sep def walk_through_files(path, file_extension=''): for (dirpath, dirnames, filenames) in os.walk(path): for filename in filenames: if filename.endswith(file_extension): yield [dirpath + os.sep, filename] for path, file in walk_through_files ( src_dir ): #print ( path + " + " + file ) outdir = file[0].lower() + os.sep # print ( outdir ) if ( not os.path.exists( outdir ) ): os.mkdir( outdir ) # Clean up filename outfile = file.lower() outfile = re.sub(r' |\(.*\)|\'|,', '', outfile) outfile = re.sub(r'\.prg$', '', outfile) print ( path + file + " -> " + dest_dir + outdir + outfile ) # Rename ISO file os.rename( path + file, outdir + outfile ) print( 'Done!' )