import os

print(f"Operating system: {os.name}")

# Execute command
if os.name == "nt":
    # os.system("dir")
    pass
else:
    os.system("ls")

print(f'\nCurrent working directory is "{os.getcwd()}"')
# print("\nList directory")
# print(os.listdir("."))

print("\nAktuální soubor")
current_file_path = os.path.realpath(__file__)
print(f"{__file__}, {current_file_path}")

print(os.path.dirname(current_file_path))

os.chdir(os.path.dirname(current_file_path))
print(f'\nCurrent working directory is "{os.getcwd()}"')

print('Make directory "foo"')
try:
    os.mkdir("foo")
    print("Folder created")
except FileExistsError:
    print('"foo" already exists')

print("Make directory recursive")
os.makedirs("foo/bar", exist_ok=True)

print("Rename file or directory")
try:
    os.rename("foo", "bar")
except FileExistsError:
    print('"bar" already exists')

os.removedirs("bar/bar")
