HowTo: Move a File to Another FileGallery

Please note that this post was migrated to my new blog platform. There may be bad formating, broken links, images, downloads and so on. If you need an item on this page, please contact me and I will do my best to get it from my backups.

~E
I'm going to start posting a lot of my old Duncan Nuggets (as Dave Burke likes to call them) here for others to start reading.  This is the first of a lot to come.

How to move a file from one FileGallery to another 
NOTE: This script was written for Community Server 2.1 RTM. 

This method uses a stored procedure to move a single file (aka Post) to another File Gallery (aka Section).  Attached is an SQL script file named move_file_to_filegallery.zip that when executed, will create a stored procedure named _move_file_to_filegallery in your database. 

After the sproc is created, you can execute it by running the following command:

EXEC _move_file_to_filegallery @PostID, @toSectionID, @ClearTags

You need two bits of information beforing executing:
  • @PostID - This is the PostID of the file you want to move. 
  • @toSectionID - This is the SectionID of the File Gallery you want to move the file to.
Following the examples above now that we have the two required integers, we can now execute the sproc to move the file.  The line would read:

EXEC _move_file_to_filegallery @PostID = 234, @toSectionID = 543125, @ClearTags = 1

NOTE: It is recommended to always clear the Tags, since they only exist in the previous FileGallery and not the new one.  So leave it @ClearTags = 1.
There is also error checking built in, so view the Messages for any errors that may have occurred.

> Revision History
> About the author