-
Notifications
You must be signed in to change notification settings - Fork 0
/
move_files.py
31 lines (25 loc) · 1.39 KB
/
move_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import shutil
from datetime import datetime
def move_files_to_folder(source_folder, destination_folder, file_prefixes):
# Create a datetime string for the folder name
current_datetime = datetime.now().strftime("%Y%m%d_%H%M%S")
# Create the destination folder with the datetime string
destination_folder_with_datetime = os.path.join(destination_folder, current_datetime)
os.makedirs(destination_folder_with_datetime, exist_ok=True)
# Iterate over files in the source folder
for filename in os.listdir(source_folder):
for file_prefix in file_prefixes:
if filename.startswith(file_prefix):
# Construct the source and destination paths
source_path = os.path.join(source_folder, filename)
destination_path = os.path.join(destination_folder_with_datetime, filename)
# Move the file to the destination folder
shutil.move(source_path, destination_path)
print(f"Moved {filename} to {destination_folder_with_datetime}")
if __name__ == "__main__":
# Example usage
source_folder = "./"
destination_folder = "./results"
file_prefixes = ["glom_spikes","pc_spikes","io_spikes","golgi_spikes","basket_spikes","stellate_spikes","granule_spikes","pf-PC","sim_description","1_"]
move_files_to_folder(source_folder, destination_folder, file_prefixes)