Last active
September 8, 2019 10:50
-
-
Save Danik/10bc6eb7b9b248feb5a17bdda40a5337 to your computer and use it in GitHub Desktop.
Revisions
-
Danik revised this gist
Sep 8, 2019 . 1 changed file with 2 additions and 4 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 @@ -3,7 +3,7 @@ import os import shutil # Rename files named for example 'tile_0.png', 'tile_1.png'... in orig_files_folder # to the names given in the des_tile_names array (based on their index in the array) file_ext = ".png" @@ -15,14 +15,13 @@ dest_file_names = [ "grass_top", #tile_0 "grass_side", #tile_1 "grass_bottom", #... "dirt_top", "dirt_side", "dirt_bottom" ] def main(): if not os.path.exists(orig_files_folder): print('Folder ' + orig_files_folder + ' not found!') return @@ -32,7 +31,6 @@ def main(): i = 0 for dest_file_name in dest_file_names: source_path = os.path.join(orig_files_folder, orig_file_base_name + str(i) + file_ext) if os.path.exists(source_path): -
Danik revised this gist
Sep 8, 2019 . 1 changed file with 11 additions and 6 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 @@ -3,23 +3,26 @@ import os import shutil # Rename files named 'tile_0.png', 'tile_1.png'... in orig_files_folder # to the names given in the des_tile_names array (based on their index in the array) file_ext = ".png" orig_files_folder = "exported_tiles" orig_file_base_name = "tile_" dest_files_folder = "renamed_tiles" dest_file_names = [ "grass_top", #tile_0 "grass_side", #tile_1 "grass_bottom", "dirt_top", "dirt_side", "dirt_bottom" ] def main(): if not os.path.exists(orig_files_folder): print('Folder ' + orig_files_folder + ' not found!') return @@ -29,10 +32,11 @@ def main(): i = 0 for dest_file_name in dest_file_names: source_path = os.path.join(orig_files_folder, orig_file_base_name + str(i) + file_ext) if os.path.exists(source_path): dest_path = os.path.join(dest_files_folder, dest_file_name + file_ext) print("Copying '" + source_path + "' to '" + dest_path + "'") # os.rename(source_path, dest_path) # Rename file shutil.copy(source_path, dest_path) # Copy file @@ -41,5 +45,6 @@ def main(): i+=1 if __name__ == '__main__': main() -
Danik created this gist
Sep 8, 2019 .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,45 @@ # Python 3 import os import shutil # Rename files named for example 'tile_0.png', 'tile_1.png'... in orig_files_folder # to the names given in the des_tile_names array (based on their index in the array) orig_files_folder = "exported_tiles" orig_file_base_name = "tile_" dest_files_folder = "renamed_tiles" dest_file_names = [ "grass_top", #tile_0.png "grass_side", #tile_1.png "grass_bottom", #... "dirt_top", "dirt_side", "dirt_bottom" ] def main(): if not os.path.exists(orig_files_folder): print('Folder ' + orig_files_folder + ' not found!') return if not os.path.exists(dest_files_folder): os.mkdir(dest_files_folder) i = 0 for dest_file_name in dest_file_names: source_path = os.path.join(orig_files_folder, orig_file_base_name + str(i) + '.png') if os.path.exists(source_path): dest_path = os.path.join(dest_files_folder, dest_file_name + '.png') print("Copying '" + source_path + "' to '" + dest_path + "'") # os.rename(source_path, dest_path) # Rename file shutil.copy(source_path, dest_path) # Copy file else: print('File ' + source_path + ' not found, skipping.') i+=1 if __name__ == '__main__': main()