My Attachment Diorectories got messed up after a path change I need help moving

Started by Mareid, March 19, 2025, 08:52:24 AM

Previous topic - Next topic

Mareid

I had a lot of errors, and with a lot of help from this board, managed to fixe the attachment path which corrected the errors.  I had originally set the forum to month/year storing of the attachments.  Now I've got it set to manual, and I want to move the attachments from the months and years.  The first set worked fine, now I get no files moved, although I know there are files in the directory...I can see them.  I suspect it has to do with the index file in each directory.  Is there anyhing I can do to flatten out the directories, or at least make them available so the posts don't have error messages? At worst it there a way to mass delete attachments from posts?  Sadly all the work I did on pictorial help files will be gone. 


Kindred

if you just want to remove them -- then delete the files and run the "clean up attachments" routine - but be aware, this is non-recoverable. Once attachments are removed, they would have to be manually added back to any post by editing the post and re-attaching a new copy of the file.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

shawnb61

What is the total # of attachments?

If the # is not too high, I'd be tempted to move them manually, all to 1 folder, then fix the folder on the attachment record via sql.  Simple & fast.

In general, when having attachment folder issues, DO NOT RUN THE ATTACHMENT INTEGRITY CHECK.  Its fix for any issue found is to delete the attachment.  (It assumes you did some file cleanup & are bringing the db in sync.  So most issues involving folders result in mass deletions...)

Moving attachments in bulk via the ui generally works, not sure what the specific issue here might be.  Not sure I'd do it for very high volume, tho.
A question worth asking is born in experience & driven by necessity. - Fripp

Mareid

There aren't many and it seems a good solution.  I may need to ask for help on the SQL part.  Thanks for the suggestion

Mareid


shawnb61

If you really have all the attachments in a single folder, the fix is actually kinda easy.

The most important part is to get the folder number correct... 

In your Attachment Directories screen, you see a list of the folders.  The position in that list is the folder ID, starting from 1.  I.e., if the very first folder listed on Attachment Directories is where you are moving everything, then your folder ID is 1.  If you moved everything to the 3rd item on that list, then your folder ID is 3. 

It may help to browse around the attachments table in phpmyadmin & review the folder IDs.

Once you're confident you have the right folder ID, the steps are:

1.  BACKUPS!!!!
2.  In the SQL window in phpmyadmin, issue the following command & press GO:
UPDATE smf_attachments SET id_folder = x;
Where "x" is the folder ID you identified earlier.  If your prefix isn't "smf_", then change that, too.

After doing this, when you return to the Attachment Directories, you should see all your files are now in that folder.

Also, browsing attachments in the admin console, you should be able to click on any attachment to view/download. 

And if you browse the smf_attachments table in phpmyadmin, the folders should all match what you set them to.

If all goes well, you're done.  You can brag to your friends that you're a developer.

If not, restore that table from backup...

Good luck!
A question worth asking is born in experience & driven by necessity. - Fripp

Advertisement: