Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9142955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:54:16+00:00 2026-06-17T09:54:16+00:00

A legacy web application I’ve inherited control over seems to have hit the maximum

  • 0

A legacy web application I’ve inherited control over seems to have hit the maximum number of subdirectories in a folder on my web server. Whenever an article is created in the system, it’s static content is placed in a subdirectory of the document root matching the pattern /uploads/story/{STORY_ID}/. But now the system is unable to create any new directories in the /uploads/story/ folder.

I’d like to address this in 2 steps, but I’m not sure how to run the necessary linux commands to achieve this. Would you be able to help?

  1. As a temporary fix to buy me more time to implement a better directory structure, I’d like to archive the static content of all stories with a STORY_ID of less than 1000. These should be moved from /uploads/story/ to /uploads/story_archive/.

  2. I’ll change the upload path to be /uploads/story/{THOUSANDS}/{STORY_ID}/ in the code, but will need to be able to move all folders within /uploads/story/ into this format. e.g. /uploads/story/65312/ would become /uploads/story/65/65312/. How can I do this?

Edit

Fixing (1) was as simple as running:

$ cd /path/to/uploads/
$ mkdir story_archive
$ for i in {1..999}; do mv story/$i story_archive/; done
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:54:18+00:00Added an answer on June 17, 2026 at 9:54 am

    Given that you are sure /uploads/story/* will give you a number in the * part, you can do the following (Note: backup the whole thing just in case):

    # update this based on your actual directory
    path_to_fix=/uploads/stories
    
    # move the directories out of the way so they don't get mixed up
    mv $path_to_fix $path_to_fix/../temp
    mkdir $path_to_fix > /dev/null 2>&1
    
    # get all directories to be moved
    dirs=$(ls $path_to_fix/../temp)
    
    # for each of them
    for d in $dirs; do
      # get the basename, which is store_id
      id=$(basename $d)
      # divide by 1000
      sub=$((id / 1000))
      # create the appropriate directory
      mkdir $path_to_fix/$sub > /dev/null 2>&1
      # move the original directory to that sub-directory
      mv $path_to_fix/../temp/$d $path_to_fix/$sub
    done
    
    # cleanup
    rm -Rf $path_to_fix/../temp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inherited a legacy web application that contains API credentials for a Twitter
I have one legacy web application based on struts2 (primarily using annotation). While debugging
We have a legacy web application (not Spring based) and are looking for best
I have the 'luck' of develop and enhance a legacy python web application for
I downloaded nUnit and TestDriven.net. I have a legacy Web Site application and I
I maintain a legacy ASP.Net Web application (using .Net 2.0 + SQL Server 2005
I have a Asp.net web application running with the following config setting. <xhtmlConformance mode=Legacy/>
We have a legacy ASP.NET web site (not web application, so I can freely
I have a legacy web application that is targeted for IE 6 and is
I have a new MVC3 application with a few legacy Web Form pages. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.