First, a warning. This program is kinda dangerous; we rename and modify images. Please make sure you have a backup of the images!

Load KnotTheory`

SetDirectory["c:/scott/math.berkeley.edu/Work/Mathematica/KnotAtlas\
"];

<< KnotTheory`

Some definitions which probably should be in KnotTheory`

AllKnots[n_] := Cases[AllKnots[], Knot[n, __]]

AllLinks[n_, t_] := Cases[AllLinks[], Link[n, t, _]]

NameString[
          Knot[n_Integer?(# ≤ 10 &), 
            k_Integer]] /; (k ≤ NumberOfKnots[n]) := 
      ToString[n] <> "_" <> ToString[k]

NameString[
          Knot[n_Integer?(# ≥ 11 &), Alternating, 
            k_Integer]] /; (k ≤ 
            NumberOfKnots[n, Alternating]) := "K" <> 
        ToString[n] <> "a" <> ToString[k]

NameString[
          Knot[n_Integer?(# ≥ 11 &), NonAlternating, 
            k_Integer]] /; (k ≤ 
            NumberOfKnots[n, NonAlternating]) := "K" <> 
        ToString[n] <> "n" <> ToString[k]

NameString[
          Link[n_Integer, Alternating, k_Integer]] /; (k ≤ 
            NumberOfLinks[n, Alternating]) := "L" <> 
        ToString[n] <> "a" <> ToString[k]

NameString[
          Link[n_Integer, NonAlternating, k_Integer]] /; (k ≤ 
            NumberOfLinks[n, NonAlternating]) := "L" <> 
        ToString[n] <> "n" <> ToString[k]

NameString[TorusKnot[m_Integer, n_Integer]] := "T(" <> 
        ToString[m] <> "," <> ToString[n] <> ")"

TorusKnots[Xmax_] := 
      Module[{res}, 
res = 
          Flatten[Table[
              Cases[Range[2, Min[Floor[1 + Xmax/m], m - 1]], 
                n_ /; GCD[m, n] == 1 :> 
                  TorusKnot[m, n]], {m, 3, Xmax}]]; 
Last /@ 
          Sort[{Crossings[#], #} & /@ res]
]

Load WikiLink` (optional) and login as a robot.

\(installPath = "c:\scott\math.berkeley.edu\Work\Mathematica\KnotAtlas\"\)

SetDirectory[installPath];

<< WikiLink`

SetJarPath[installPath];

\(CreateWikiConnection["http://katlas.math.toronto.edu/w/index.php", "ScottImageRobot", "foobar"]\)

Do stuff!

\(\(imagePath = "c:/scott/math.berkeley.edu/Work/Mathematica/KnotAtlas/images/thistlethwaite/gif/";\)\)

Define the collection of knots we're working with.

knots = Take[AllKnots[11, NonAlternating], {155, 156}];

SetDirectory[imagePath];

imageFileName[K_Knot] := 
      NameString[K] <> ".gif"
imageFileName[L_Link] := 
      NameString[L] <> ".gif"
imageFileName[T_TorusKnot] := NameString[T] <> ".jpg"

For Morse links:

imageFileName[K_Knot] := 
      NameString[K] <> "_ML.gif"
imageFileName[K_Link] := NameString[K] <> "_ML.gif"

Renaming files

You'll need to modify definitions as appropriate here.

oldFileName[Link[n_, Alternating, k_]] := 
      ToString[n] <> "a" <> 
        ToString[k] <> ".gif"
oldFileName[Link[n_, NonAlternating, k_]] := 
      ToString[n] <> "n" <> 
        ToString[k] <> ".gif"
oldFileName[TorusKnot[m_, n_]] := 
      ToString[m] <> "." <> ToString[n] <> "_240.jpg"

oldFileName[Knot[11, Alternating, k_]] := "11a" <> 
        ToString[k] <> "_ML.gif"
oldFileName[Knot[11, NonAlternating, k_]] := "11n" <> 
        ToString[k] <> "_ML.gif"

oldFileName[Link[n_, Alternating, k_]] := 
      ToString[n] <> "a" <> 
        ToString[k] <> "_ML.gif"
oldFileName[Link[n_, NonAlternating, k_]] := 
      ToString[n] <> "n" <> ToString[k] <> "_ML.gif"

renameImage[K_] := 
      RenameFile[oldFileName[K], imageFileName[K]]

renameImage /@ knots;

Resizing images with transparent background

Life will be much easier if all the images are of the same size. Mostly, this isn't the case for images from the old Knot Atlas.

newImageSize = "240x240";

Change the image here to one you'd like to test this out on.

Run["montage L6a1.gif -geometry  \"" <> 
        newImageSize <> "+0+0>\" -background none test.gif"]

resizeCommand[K_Link] := "montage " <> 
        imageFileName[K] <> " -geometry  \"" <> 
        newImageSize <> "+0+0>\" -background none " <> 
        imageFileName[K]

This one could take a while; go make some coffee!

scriptName = "resize.bat";

resizeCommands = 
        StringJoin @@ (resizeCommand[#] <> "\r\n" & /@ 
              knots);

resizeCommands = 
        StringJoin @@ (resizeCommand[#] <> "\r\n" & /@ 
              AllLinks[11, NonAlternating]);

WriteString[OpenWrite[scriptName], resizeCommands]; 
    Close[scriptName];

Run[scriptName]

DeleteFile[scriptName]

Uploading images

ShowJavaConsole[]

imageDescription[K_] := ""

Note here that WikiLink` doesn't listen to SetDirectory[], so we have to specify a full path.

uploadFile[K_] := 
      WikiUploadFile[imagePath <> imageFileName[K], 
        imageDescription[K]]

uploadFile[Link[6, Alternating, 1]]

Position[knots, Link[10,  Alternating,  166]]

This one could take a while; go make some coffee!

(Print["Uploading " <> ToString[#]]; Print[uploadFile[#]]; 
          Pause[1];) & /@ knots