script for easy download
Browse files- download_files.sh +0 -0
- get_download_links.py +29 -0
download_files.sh
ADDED
The diff for this file is too large to render.
See raw diff
|
|
get_download_links.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
# Base URL for the links
|
4 |
+
base_url = "https://huggingface.co/datasets/rulins/raw_data/resolve/main"
|
5 |
+
|
6 |
+
# List to store the generated URLs
|
7 |
+
urls = []
|
8 |
+
|
9 |
+
# Walk through the directory
|
10 |
+
for root, dirs, files in os.walk('.'):
|
11 |
+
for file in files:
|
12 |
+
if file.endswith('.jsonl'):
|
13 |
+
# Get the relative path
|
14 |
+
relative_path = os.path.relpath(os.path.join(root, file), '.')
|
15 |
+
# Replace backslashes with forward slashes for URLs
|
16 |
+
relative_path = relative_path.replace(os.sep, '/')
|
17 |
+
# Generate the URL
|
18 |
+
url = f"{base_url}/{relative_path}?download=true"
|
19 |
+
urls.append((url, relative_path))
|
20 |
+
|
21 |
+
# Create a bash script
|
22 |
+
with open('download_files.sh', 'w') as bash_script:
|
23 |
+
bash_script.write("#!/bin/bash\n\n")
|
24 |
+
for url, relative_path in urls:
|
25 |
+
bash_script.write(f"if [ ! -f \"{relative_path}\" ]; then\n")
|
26 |
+
bash_script.write(f" wget -O \"{relative_path}\" \"{url}\"\n")
|
27 |
+
bash_script.write("fi\n\n")
|
28 |
+
|
29 |
+
print("Bash script 'download_files.sh' has been created.")
|