I am trying to write a python script to save me time copy/pasting updated files.
This is what i got so far:
import os
import shutil
src_files = [
'C:/orig/path/to/some/file/module_some_file.php',
'C:/orig/path/to/some/other/file/module_some_file.php',
'C:/orig/path/to/some/third/file/module_with_diff_name_after_module.php',
# ....
]
dest_files = [
'C:/copy/path/to/some/file/module_some_file.php',
'C:/copy/path/to/some/other/file/module_some_file.php',
'C:/orig/path/to/some/third/file/module_with_diff_name_after_module.php',
# ....
]
for i in range(len(src_files)):
FILE_DIR=os.path.dirname(dest_files[i])
if not os.path.exists(FILE_DIR):
os.makedirs(FILE_DIR)
if (os.path.isfile(src_files[i])):
shutil.copy(src_files[i], dest_files[i])
This way works but i would like to achieve that i enter for example py copy.py module --src "C:/orig/path/to/some" --dest "C:/copy/path/to/some" and the script will search all files where name contains "module". A wildcard kind of solution. My question(s), can i achieve what i want with python? And can someone help me with substituting the lists for some elegant wildcard/search solution?
Environment: Windows / python 3.6.1
This is literally my first python script so please have some mercy :)
copymodule it will mask it.