View difference between Paste ID: DEhnUhTg and NW7sVctd
SHOW: | | - or go back to the newest paste.
1
import os
2
import shutil
3
from datetime import date
4
5
today = date.today()
6
print("Run date:", today)
7
8
copy_from = '_ru_ru.php'
9
copy_to = [
10
    '_by_ru.php',
11
    '_by_by.php',
12
    '_en_ru.php',
13
    '_en_en.php',
14
    '_kz_ru.php',
15
    '_kz_en.php',
16
    '_kz_kz.php',
17
    '_uz_ru.php',
18
    '_uz_uz.php',
19
]
20
21
copy_from_short = '_ru.php'
22
copy_to_short = [
23
    '_by.php',
24
    '_by.php',
25
    '_en.php',
26
    '_kz.php',
27
    '_uz.php',
28
]
29
30
for root, dirs, files in os.walk('.'):
31
    files = [f for f in files if f.endswith(copy_from_short) and not f.endswith(copy_from)]
32
    if files:
33
        print(root)
34
        for f in files:
35
            for new_file in [f.replace(copy_from_short, nf) for nf in copy_to_short]:
36
                if os.path.exists(os.path.join(root, new_file)):
37
                    print(f'  "{new_file}" is exists, skip')
38
                else:
39
                    print(f'  copy "{f}" to "{new_file}"')
40
                    shutil.copy(
41
                        os.path.join(root, f),
42
                        os.path.join(root, new_file),
43
                    )
44
45
for root, dirs, files in os.walk('.'):
46
    files = [f for f in files if f.endswith(copy_from)]
47
    if files:
48
        print(root)
49
        for f in files:
50
            for new_file in [f.replace(copy_from, nf) for nf in copy_to]:
51
                if os.path.exists(os.path.join(root, new_file)):
52
                    print(f'  "{new_file}" is exists, skip')
53
                else:
54
                    print(f'  copy "{f}" to "{new_file}"')
55
                    shutil.copy(
56
                        os.path.join(root, f),
57
                        os.path.join(root, new_file),
58
                    )
59
60