MikaelTradera commited on
Commit
ea64a92
·
verified ·
1 Parent(s): fb30506

Create dlmodels.sh

Browse files
Files changed (1) hide show
  1. dlmodels.sh +48 -0
dlmodels.sh ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Check if a file argument is provided
4
+ if [[ -z "$1" ]]; then
5
+ echo "Usage: $0 <input_file>"
6
+ exit 1
7
+ fi
8
+
9
+ # Set the input file from the first argument
10
+ INPUT_FILE="$1"
11
+
12
+ # Function to check file existence and download integrity
13
+ download_file() {
14
+ local filepath="$1"
15
+ local url="$2"
16
+
17
+ # If file already exists
18
+ if [[ -f "$filepath" ]]; then
19
+ # Get remote file size
20
+ remote_size=$(curl -sI "$url" | awk '/Content-Length/ {print $2}' | tr -d '\r')
21
+ # Get local file size
22
+ local_size=$(stat -c%s "$filepath")
23
+
24
+ # Check if file sizes match
25
+ if [[ "$remote_size" == "$local_size" ]]; then
26
+ echo "File $filepath already exists and is complete."
27
+ return 0
28
+ else
29
+ echo "File $filepath is incomplete or corrupted, re-downloading..."
30
+ rm -f "$filepath" # Remove the corrupted file
31
+ fi
32
+ fi
33
+
34
+ # Download the file
35
+ wget -c -O "$filepath" "$url"
36
+ }
37
+
38
+ # Process each line in the specified input file
39
+ cat "$INPUT_FILE" | while read -r line; do
40
+ # Split each line into filepath and URL
41
+ filepath=$(echo "$line" | awk '{print $1}')
42
+ url=$(echo "$line" | awk '{print $2}')
43
+
44
+ # Call the download function
45
+ download_file "$filepath" "$url" &
46
+ done
47
+
48
+ wait