Answers.Body: <p>For Craft 2, You can write a <a href="https://pluginfactory.io/" rel="nofollow noreferrer">plugin</a> that listens to the <a href="https://craftcms.com/docs/plugins/events-reference#assets-onBeforeSaveAsset" rel="nofollow noreferrer">onBeforeSaveAsset</a> event, and changes the title from the <code>asset</code> parameter to whatever you want. Something like:</p>
  
  <pre><code>if ($event-&gt;params['isNewAsset])
  {
      $asset = $event-&gt;params['asset']
      $asset-&gt;getContent()-&gt;title = 'My New Title';
  }
  </code></pre>
  
  <p>For Craft 3, you can write a plugin that listens to the <a href="https://docs.craftcms.com/api/v3/craft-elements-asset.html#EVENT_BEFORE_HANDLE_FILE-detail" rel="nofollow noreferrer">BEFORE_HANDLE_FILE</a> event like so:</p>
  
  <pre><code>Event::on(Asset::class, Asset::EVENT_BEFORE_HANDLE_FILE, function(AssetEvent $event) {
      $asset = $event-&gt;asset;
      $asset-&gt;title = 'My New Title';
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-12T14:57:04.927Z
Answers.Text: Thanks Brad, will look into doing that if I need to! Out of interest, any reason why the default behavior changes the case instead of just replacing separators with spaces?
Answers.UserDisplayName: michaelroper
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-12T17:22:14.340Z
Answers.Text: Craft title cases (https://en.wikipedia.org/wiki/Letter_case#Case_styles) the file name. Just so happens that doesn't play well with acronyms like "CMS"
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-11T16:15:44.050Z
Answers.LastActivityDate: 2017-12-17T21:50:52.410Z
Answers.LastEditDate: 2017-12-17T21:50:52.410Z
Answers.UserDisplayName: Brad Bell
Body: <p>Is there any way to control the formatting of an asset's title that is created from the filename on upload? </p>
  
  <p>At the moment, if you uploaded a file called <code>Craft-CMS.pdf</code> it would create the title as <code>Craft Cms</code> - where in most cases I you would expect the uppercase of <code>CMS</code> to remain intact.</p>
  
  <p>I see there is a config setting for <code>filenameWordSeparator</code>, but nothing related to the pattern used to created the title - is there anyway I'm not seeing to configure this?</p>
  
Tags: <assets><upload><meta>
Title: How to control the format of an asset's Title
ThreadText: # How to control the format of an asset's Title
  
  (Asked by: username_0 on 2016-05-11)
  
  Is there any way to control the formatting of an asset's title that is created from the filename on upload?
  
  At the moment, if you uploaded a file called `Craft-CMS.pdf` it would create the title as `Craft Cms` - where in most cases I you would expect the uppercase of `CMS` to remain intact.
  
  I see there is a config setting for `filenameWordSeparator`, but nothing related to the pattern used to created the title - is there anyway I'm not seeing to configure this?
  
  **Tags:** assets, upload, meta
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-11. Score: 4 | Accepted answer
  
  For Craft 2, You can write a [plugin](https://pluginfactory.io/) that listens to the [onBeforeSaveAsset](https://craftcms.com/docs/plugins/events-reference#assets-onBeforeSaveAsset) event, and changes the title from the `asset` parameter to whatever you want. Something like:
  
  ```
  if ($event->params['isNewAsset])
  {
      $asset = $event->params['asset']
      $asset->getContent()->title = 'My New Title';
  }
  
  ```
  
  For Craft 3, you can write a plugin that listens to the [BEFORE\_HANDLE\_FILE](https://docs.craftcms.com/api/v3/craft-elements-asset.html#EVENT_BEFORE_HANDLE_FILE-detail) event like so:
  
  ```
  Event::on(Asset::class, Asset::EVENT_BEFORE_HANDLE_FILE, function(AssetEvent $event) {
      $asset = $event->asset;
      $asset->title = 'My New Title';
  }
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks username_1, will look into doing that if I need to! Out of interest, any reason why the default behavior changes the case instead of just replacing separators with spaces?  
  > **username_1**: Craft title cases (https://en.wikipedia.org/wiki/Letter_case#Case_styles) the file name. Just so happens that doesn't play well with acronyms like "CMS"  
  
  ---
  
  