Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)
OpenAssistant Conversations (oasst2)
Create a python script that sorts files on the desktop into separate folders based on…
In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
- User
Create a python script that sorts files on the desktop into separate folders based on their file type. The script should prompt the user for the source and destination paths, and then guide the user through the process of setting up the file types dictionary and running the sorting code.
- Assistant
Sure thing, please find the code below:
import logging import os import shutil import sys from collections import defaultdict from pathlib import Path def sort_files_by_extension(input_path: str, output_path: str) -> None: """ Sort files into separate folders based on their extension. :param input_path: Path to the input folder. :param output_path: Path to the output folder. :return: None. """ logging.basicConfig(level=logging.INFO) input_directory = Path(input_path) if not input_directory.is_dir: raise NotADirectoryError(f'{input_path} is not a directory.') output_directory = Path(output_path) if not output_directory.is_dir: logging.info(f'{output_path} is not a directory. Creating it now.') os.makedirs(output_directory) file_list = [f for f in input_directory.glob('**/*')] logging.info(f"Found {len(file_list)} files") extension_dict = defaultdict(list) for file in file_list: if file.is_file(): extension_dict[file.suffix[1:]].append(file.as_posix()) logging.info(f"Found {len(extension_dict)} extensions") for key, value in extension_dict.items(): output_directory.joinpath(key).mkdir(exist_ok=True) logging.info(f"Moving {len(value)} files to {key} folder") for file in value: logging.info(f"Moving {file} to {key} folder") shutil.move(file, output_directory.joinpath(key)) if __name__ == "__main__": sort_files_by_extension(sys.argv[1], sys.argv[2]) print("Done!")
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)