Proactively organizing files in subfolders

Handling large files

If you're setting up a new website, and you expect to have large number of files uploaded, you'll want to proactively set up file paths to organize those files. If you don't, you run the risk of serious performance problems as your website grows larger.

If you already have a lot of files, you might find Optimizing file paths: Organizing files in subfolders useful. Once you've moved your files around, this article can help you configure your website to keep the files organized in the future.

If you're just setting up your website and haven't started adding content yet, you can use these instructions to help proactively create directories for files that will be uploaded in the future.

Custom date formats

The easiest way to break content down is to use dates. You can use custom date formats with the PHP date format syntax with tokens in Drupal to break your directories down by year, month, day, and so on. Think about the content your website will be using, and choose the best format for your needs.

The custom date format examples we will use here include the following:

  • Y - A full numeric representation of a year, four digits
  • m - Numeric representation of a month, with leading zeros
  • d - Day of the month, two digits with leading zeros

The Drupal token will look like this if you want to use a YYYY/mm/dd format:


File and field path token settings

Once you've decided on your date format, you'll need to update the paths that the modules upload files to by default. For each file field in your content type, update the File directory textbox to use the appropriate [current-date:custom:?] tokens.

You can find either of these settings by:

  1. As an administrator, go to Structure > Content types.
  2. Select a content type, and then click its manage fields link.
  3. Select a field that has a file upload ability, and click its edit link.

Or, you can change the general Drupal settings.

  • Basic Drupal settings

    Update the File directory setting for each field with the tokens you want to use. This location varies depending on the module and/or field being used.

  • Use the File (Field) Paths module

    The File (Field) Paths module presents the same kind of path settings as basic Drupal, but it adds a number of helpful options. When this module is enabled, the File directory setting is replaced with a collapsed Show File (field) path settings field set. Expand this fieldset to find the File path field. Enter your new path in this field.

    This module also includes support for the Pathauto and Transliteration modules, which can help correct file names and paths when they're created. It can also do a retroactive change to your files and their paths, but you should approach this with caution and test it carefully before you try it in production.

Contact supportStill need assistance? Contact Acquia Support