|
import os |
|
|
|
|
|
base_url = "https://huggingface.co/datasets/rulins/raw_data/resolve/main" |
|
|
|
|
|
urls = [] |
|
|
|
|
|
for root, dirs, files in os.walk('.'): |
|
for file in files: |
|
if file.endswith('.jsonl'): |
|
|
|
relative_path = os.path.relpath(os.path.join(root, file), '.') |
|
|
|
relative_path = relative_path.replace(os.sep, '/') |
|
|
|
url = f"{base_url}/{relative_path}?download=true" |
|
urls.append((url, relative_path)) |
|
|
|
|
|
with open('download_files.sh', 'w') as bash_script: |
|
bash_script.write("#!/bin/bash\n\n") |
|
for url, relative_path in urls: |
|
|
|
dir_path = os.path.dirname(relative_path) |
|
|
|
if dir_path: |
|
bash_script.write(f"mkdir -p \"{dir_path}\"\n") |
|
bash_script.write(f"if [ ! -f \"{relative_path}\" ]; then\n") |
|
bash_script.write(f" wget -O \"{relative_path}\" \"{url}\"\n") |
|
bash_script.write("fi\n\n") |
|
|
|
print("Bash script 'download_files.sh' has been created.") |
|
|