-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathatomiswave_gdi_to_chd.sh
More file actions
executable file
·55 lines (44 loc) · 1.32 KB
/
atomiswave_gdi_to_chd.sh
File metadata and controls
executable file
·55 lines (44 loc) · 1.32 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Folder to search for files; use the current directory if none provided
TARGET_DIR="${1:-.}"
# Check if chdman is installed
if ! command -v chdman &> /dev/null
then
echo "chdman could not be found. Please install via Homebrew (brew install rom-tools)."
exit 1
fi
# Convert function for .gdi files
convert_to_chd() {
local input_file="$1"
local output_file="${input_file%.*}.chd"
# Check if the output file already exists
if [ -e "$output_file" ]; then
echo "Skipping $input_file: $output_file already exists."
return 0
fi
echo "Converting $input_file to $output_file..."
# Check if input is .gdi and set appropriate command
if [[ "$input_file" == *.gdi ]]; then
chdman createcd -i "$input_file" -o "$output_file"
else
echo "Unsupported file type: $input_file"
return 1
fi
if [ $? -eq 0 ]; then
echo "Successfully converted $input_file to $output_file."
else
echo "Failed to convert $input_file."
fi
}
# Loop through each .gdi file in the target directory
shopt -s nullglob
for file in "$TARGET_DIR"/*.gdi; do
convert_to_chd "$file"
done
# Check if no .gdi files were found
if [ $? -ne 0 ]; then
echo "No .gdi files found in $TARGET_DIR."
exit 1
fi
shopt -u nullglob
echo "All conversions completed."