automate movement of png icons for launcher
This commit is contained in:
parent
5bf3cd205c
commit
0b05c0ac38
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import getpass
|
import getpass
|
||||||
|
import shutil
|
||||||
|
|
||||||
def replace_word_in_files(target_word, replacement_word, folder_path=".", dest_path=".."):
|
def replace_word_in_files(target_word, replacement_word, folder_path=".", dest_path=".."):
|
||||||
# Loop through all files in the specified folder
|
# Loop through all files in the specified folder
|
||||||
@ -19,6 +20,20 @@ def replace_word_in_files(target_word, replacement_word, folder_path=".", dest_p
|
|||||||
|
|
||||||
print(f"Replaced '{target_word}' with '{replacement_word}' in {filename}")
|
print(f"Replaced '{target_word}' with '{replacement_word}' in {filename}")
|
||||||
|
|
||||||
|
def copy_png_files_up():
|
||||||
|
current_dir = os.getcwd() # Get the current working directory
|
||||||
|
parent_dir = os.path.abspath(os.path.join(current_dir, '..')) # Get the parent directory
|
||||||
|
|
||||||
|
# Iterate through all files in the current directory
|
||||||
|
for filename in os.listdir(current_dir):
|
||||||
|
if filename.endswith(".png"): # Check if the file is a .png file
|
||||||
|
source_path = os.path.join(current_dir, filename)
|
||||||
|
destination_path = os.path.join(parent_dir, filename)
|
||||||
|
|
||||||
|
# Copy the .png file to the parent directory
|
||||||
|
shutil.copy(source_path, destination_path)
|
||||||
|
print(f"Copied: {filename} to {parent_dir}")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Get the current Ubuntu username
|
# Get the current Ubuntu username
|
||||||
username = getpass.getuser()
|
username = getpass.getuser()
|
||||||
@ -27,4 +42,5 @@ if __name__ == "__main__":
|
|||||||
target_word = "userhere"
|
target_word = "userhere"
|
||||||
|
|
||||||
replace_word_in_files(target_word, username)
|
replace_word_in_files(target_word, username)
|
||||||
|
copy_png_files_up()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user