forked from Alexey/DAS_2024_1
24 lines
657 B
Python
24 lines
657 B
Python
import os
|
|
import shutil
|
|
|
|
def find_shortest_file(directory):
|
|
shortest_file = None
|
|
shortest_file_length = float('inf')
|
|
for file in os.listdir(directory):
|
|
file_path = os.path.join(directory, file)
|
|
if os.path.isfile(file_path) and len(file) < shortest_file_length:
|
|
shortest_file = file_path
|
|
shortest_file_length = len(file)
|
|
return shortest_file
|
|
|
|
def move_file(source, destination):
|
|
shutil.move(source, destination)
|
|
|
|
directory = "/var/data"
|
|
|
|
shortest_file = find_shortest_file(directory)
|
|
|
|
if shortest_file is not None:
|
|
destination = "/var/result/data.txt"
|
|
move_file(shortest_file, destination)
|