@@ -36,7 +36,13 @@ convert(){
3636 # Folder where images downloaded from the Smogon spreadsheet are stored.
3737 local files=" downloads/"
3838 local formDS
39+ local formDSAnimated
3940 formDS=$( jq . forms.json)
41+ formDSAnimated=" $formDS " # default to same as formDS
42+ if [ -f forms-animated.json ]; then
43+ # Merge forms-animated.json into forms.json (animated overrides original)
44+ formDSAnimated=$( jq -n --argjson base " $formDS " --argjson animated " $( jq . forms-animated.json) " ' $base * $animated' )
45+ fi
4046 # echo "$formDS" | jq -r '.["885"]'
4147
4248 cd " $files " || exit
@@ -95,13 +101,18 @@ convert(){
95101 else
96102 echo " [+] Copying GMax $smogonName to $bwDestination /$pokemonID .$fileExt "
97103 if [ " $fileExt " == " png" ]; then
98- cp " $smogonName " " $destination /$pokemonID .$fileExt "
104+ mv " $smogonName " " $destination /$pokemonID .$fileExt "
99105 fi
100- cp " $smogonName " " $bwDestination /$pokemonID .$fileExt "
106+ mv " $smogonName " " $bwDestination /$pokemonID .$fileExt "
101107 fi
102108 fi
103109 if [ " $form " ]; then
104- pokemonName=$( echo " $formDS " | jq -r " .[\" ${id} _${form} \" ]" )
110+ # Use animated forms for .gif, regular forms for .png
111+ if [ " $fileExt " == " gif" ]; then
112+ pokemonName=$( echo " $formDSAnimated " | jq -r " .[\" ${id} _${form} \" ]" )
113+ else
114+ pokemonName=$( echo " $formDS " | jq -r " .[\" ${id} _${form} \" ]" )
115+ fi
105116
106117 if [ $? -ne 0 ] || [ " $pokemonName " == ' null' ]; then
107118 echo " [-] Form ${id} _${form} wasn't found in the JSON mapping"
@@ -113,9 +124,9 @@ convert(){
113124 if [ -n " $pokemonID " ] && [ " $pokemonID " != " null" ]; then
114125 echo " [+] Found variety by name: Moving $smogonName to $bwDestination /$pokemonID .$fileExt "
115126 if [ " $fileExt " == " png" ]; then
116- cp " $smogonName " " $destination /$pokemonID .$fileExt "
127+ mv " $smogonName " " $destination /$pokemonID .$fileExt "
117128 fi
118- cp " $smogonName " " $bwDestination /$pokemonID .$fileExt "
129+ mv " $smogonName " " $bwDestination /$pokemonID .$fileExt "
119130 else
120131 # Search all forms from Pokémon API
121132 echo " [!] Variety '$pokemonName ' not found directly. Searching in Pokémon forms..."
@@ -134,9 +145,9 @@ convert(){
134145
135146 echo " [+] Found in forms: Moving $smogonName to $bwDestination /$destFile "
136147 if [ " $fileExt " == " png" ]; then
137- cp " $smogonName " " $destination /$destFile "
148+ mv " $smogonName " " $destination /$destFile "
138149 fi
139- cp " $smogonName " " $bwDestination /$destFile "
150+ mv " $smogonName " " $bwDestination /$destFile "
140151 else
141152 echo " [!] No matching form found for $pokemonName ."
142153 fi
@@ -148,9 +159,9 @@ convert(){
148159 mkdir -p " $destination "
149160 mkdir -p " $bwDestination "
150161 if [ " $fileExt " == " png" ]; then
151- cp " $smogonName " " $destination /$id .$fileExt "
162+ mv " $smogonName " " $destination /$id .$fileExt "
152163 fi
153- cp " $smogonName " " $bwDestination /$id .$fileExt "
164+ mv " $smogonName " " $bwDestination /$id .$fileExt "
154165 fi
155166 fi
156167 done
0 commit comments