Move python scripts outside of game dir
This commit is contained in:
		
							parent
							
								
									6b717a39f7
								
							
						
					
					
						commit
						8ea7a858d0
					
				
					 2 changed files with 2 additions and 2 deletions
				
			
		
							
								
								
									
										27
									
								
								replace_special_symbols.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								replace_special_symbols.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| # flake8: noqa | ||||
| import os | ||||
| from pathlib import Path | ||||
| 
 | ||||
| 
 | ||||
| def replace_special_symbols(s: str) -> str: | ||||
|     return s.replace('!', '_PIDOR_').replace('[', '_SUPER_').replace(']', '_PEDIK_').replace('$', '_SEMENCUM_').replace('%', '_RAZRABI_PIDORASI').replace('(', '_SOSI_').replace(')', '_BEBRA_') | ||||
| 
 | ||||
| 
 | ||||
| DIRECTORY = Path('www/img') | ||||
| def cast_symbols(dir_: Path, indent: int = 0) -> int: | ||||
|     renamed = 0 | ||||
|     for file_name in os.listdir(dir_): | ||||
|         replaced = replace_special_symbols(file_name) | ||||
|         file_path = dir_ / replaced | ||||
| 
 | ||||
|         if replaced != file_name: | ||||
|             os.rename(dir_ / file_name, file_path) | ||||
|             renamed += 1 | ||||
| 
 | ||||
|         if file_path.is_dir(): | ||||
|             renamed += cast_symbols(file_path, 1) | ||||
|     print(' ' * (indent * 2) + f'>> renamed {renamed} files in {dir_}') | ||||
|     return renamed | ||||
| 
 | ||||
| 
 | ||||
| cast_symbols(DIRECTORY, 0) | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue