cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jeffrey_villine
Community Member

Replacing Files when Importing Pages

Jump to solution

Is there any way I can be prompted on keeping or replacing files when they're attached to pages I'm importing?

I reuse a lot of assets between my various courses, but I also update my pages regularly. Sometimes when I update a page in Course A, I'll delete old versions of that page from Courses B and C, then send the updated page from Course A to the others. This works perfectly in terms of keeping all the internal links stable. (Since the originals in B and C were deleted, the new page from A can keep its original name, and the internal links will continue to point to the updated page.)

However, the problem comes in when I have any files attached to those pages. Let's say X.jpg is on the page. When I send it to the other courses, it becomes X-1.jpg. Both files exist in the Files portion of my course.

I can go through files and delete al the duplicates, but all that does is make it so I have dead image links and file downloads throughout. I then have to manually go back and restore images and files.

Is there some box I need to check in settings that will make it so Canvas will check to see if I have identically-named files or other assets when I'm importing pages, then prompt me as to whether I want to replace, rename, or cancel the upload of that duplicate file?

When searching through the forums, I found numerous pages telling me that uploading files directly into the files page will give me such a prompt. But that process doesn't get a look in on page importation.

Labels (1)
0 Kudos
2 Solutions

@jeffrey_villine 

I think what you are seeing cannot be change (unfortunately).  

The way around it is to delete the files in the course you are importing into first and then do the import. Then when the import occurs you don't get the -1 added on.

Fortunately you can highlight multiple files and delete them at the same time (use the ctrl and click on individually - or click and then shift click to delete a block of files).

Not the ideal case, but at least you would not have to delete them 1 at a time.

Still more work than a nice question box that says a file with "name" already exists overwrite or create file name-1 (and then the do this with all other occurrences as well)

 

View solution in original post

As an update, I was able to get the editing to work eventually. What I had overlooked is that the file is named twice, once in an "src" tag, and once the "data-api-endpoint" tag. I think the reason my changes were reverting was because I was only changing one of them, not both.

Once you delete all you duplicate files, do the following:

  1. Run the link validator to see which pages are affected (they'll probably show up as "download=1")
  2. Open each affected page
  3. Go into edit mode
  4. Switch to HTML view
  5. With the cursor in the editing field, hit Ctrl+A to select everything, then Ctrl+C to copy it
  6. Open up a plain-text editor--preferably one with a find and replace function. I used Typora
  7. Use Ctrl+V to paste the HTML code into the plain-text editor
  8. Search (Ctrl+F) for "file/" (no quotes). This will help you find the places where you should have files that are currently missing. You're looking for an 8-digit number.
  9. Start a find and replace. In a lot of applications, this is Ctrl+H
  10. In the find menu, put the 8-digit number. We'll call this the "problem number"
  11. (meanwhile) open the FILES section of the course. Click on the file you want to replace your duplicates with. (This will usually be the "original" file.)
  12. In the URL, toward the end, you'll have an 8-digit number. This is the code for that specific asset. It doesn't matter if you change the name of the file or (I believe) if you move it to another folder int he same class. This 8-digit number will point to this specific file.
    1. This number *should* be listed in the info for the file. But it isn't.
  13. Copy the 8-digit number. We'll call this the "original number"
  14. Put the "original number" in the "replace" field, and run it. It will now search for every instance of the "problem number" and replace it with the "original number."
  15. Repeat steps 8-14 for every other missing file on the page.
  16. When satisfied, Ctrl+A to select everything in the text editor, then switch back to the HTML view on the Canvas page you're editing.
  17. Delete everything in the Canvas page. Replace it with Ctrl+V.
  18. Hit save.
  19. If you did everything correctly, all your images/files are now manifesting correctly. Any alternate text or re-sizing you had done before deleting the duplicate files will still be applied to the updated files.

I figured this out, but now I'm copying a lot of my more frequently used files to the "user" category instead of the "class" category. Writing the line that refers to a "User file" instead of a "course file" is much more cumbersome but, I'm hoping, more stable. It might not be worth it.

View solution in original post

7 Replies
jeffrey_villine
Community Member

I tried switching to HTML mode and changing the file name in the tags so it points to the file I want to replace it with. Canvas never saves this change. I change the file name, save, and see nothing is different. I go back into edit/HTML, and I see the file name is the unchanged original.

0 Kudos

@jeffrey_villine wrote:

I tried switching to HTML mode and changing the file name in the tags so it points to the file I want to replace it with. Canvas never saves this change. I change the file name, save, and see nothing is different. I go back into edit/HTML, and I see the file name is the unchanged original.


Thank you for the reply, I was looking for the same solution.

As an update, I was able to get the editing to work eventually. What I had overlooked is that the file is named twice, once in an "src" tag, and once the "data-api-endpoint" tag. I think the reason my changes were reverting was because I was only changing one of them, not both.

Once you delete all you duplicate files, do the following:

  1. Run the link validator to see which pages are affected (they'll probably show up as "download=1")
  2. Open each affected page
  3. Go into edit mode
  4. Switch to HTML view
  5. With the cursor in the editing field, hit Ctrl+A to select everything, then Ctrl+C to copy it
  6. Open up a plain-text editor--preferably one with a find and replace function. I used Typora
  7. Use Ctrl+V to paste the HTML code into the plain-text editor
  8. Search (Ctrl+F) for "file/" (no quotes). This will help you find the places where you should have files that are currently missing. You're looking for an 8-digit number.
  9. Start a find and replace. In a lot of applications, this is Ctrl+H
  10. In the find menu, put the 8-digit number. We'll call this the "problem number"
  11. (meanwhile) open the FILES section of the course. Click on the file you want to replace your duplicates with. (This will usually be the "original" file.)
  12. In the URL, toward the end, you'll have an 8-digit number. This is the code for that specific asset. It doesn't matter if you change the name of the file or (I believe) if you move it to another folder int he same class. This 8-digit number will point to this specific file.
    1. This number *should* be listed in the info for the file. But it isn't.
  13. Copy the 8-digit number. We'll call this the "original number"
  14. Put the "original number" in the "replace" field, and run it. It will now search for every instance of the "problem number" and replace it with the "original number."
  15. Repeat steps 8-14 for every other missing file on the page.
  16. When satisfied, Ctrl+A to select everything in the text editor, then switch back to the HTML view on the Canvas page you're editing.
  17. Delete everything in the Canvas page. Replace it with Ctrl+V.
  18. Hit save.
  19. If you did everything correctly, all your images/files are now manifesting correctly. Any alternate text or re-sizing you had done before deleting the duplicate files will still be applied to the updated files.

I figured this out, but now I'm copying a lot of my more frequently used files to the "user" category instead of the "class" category. Writing the line that refers to a "User file" instead of a "course file" is much more cumbersome but, I'm hoping, more stable. It might not be worth it.

@jeffrey_villine -

Wow That is quite the list of steps.

I don't know if the following will solve your problem, but I had a thought.  Is it possible to put those files that you know will end up being copied in your personal files area and then have the page link to them there.   I don't know if Canvas would import the files or just keep the link to your own file repository.

I just tried the above out.  copying a page with links to files in your MyFiles folder keeps the file there and does not copy it over to your course.

Of course that may not be feasible with what you are doing anyway.

 

nmbucklein
Instructure
Instructure

Hi @jeffrey_villine 

When it comes to importing pages that have files attached to them, it is important to import the files into the new course at the same time as the pages with the files attached. This action is what allows the files to update on the page in the new course! 

Hope that helps.

0 Kudos

The duplicating files already exist in both courses.

For instance, there's a mandatory header image I use for certain pages. The file "header.jpg" exists in Courses A, B, and C. But when I take a page that contains "header.jpg" and copy it to Course B, the system creates "header-1.jpg" rather than reuse the asset it already has.

0 Kudos

@jeffrey_villine 

I think what you are seeing cannot be change (unfortunately).  

The way around it is to delete the files in the course you are importing into first and then do the import. Then when the import occurs you don't get the -1 added on.

Fortunately you can highlight multiple files and delete them at the same time (use the ctrl and click on individually - or click and then shift click to delete a block of files).

Not the ideal case, but at least you would not have to delete them 1 at a time.

Still more work than a nice question box that says a file with "name" already exists overwrite or create file name-1 (and then the do this with all other occurrences as well)