Remove All After

This rename preset requires DOpus 12 (or later).


Removes everything after the matched text (not including the fileextension).
Very useful to quickly remove random "garbage" from filenames.

Adds an extra field to the rename dialog where you can type a regular expression:

Anything after the part of the file name which matches the regular expression will be removed.


If you have the filename This is a test.txt and you enter the regex \bis into the Remove All After field then the resulting filename will be This is.txt.


Script code:

If you just want to use the script, use the download above. The script code is reproduced here to help people browsing the forum for scripting techniques.

// Remove All After
// Removes everything following the matched regex
/* exported OnGetNewName,OnGetCustomFields */

// adds custom fields to the Rename dialog
function OnGetCustomFields(getCustomFieldData){
  getCustomFieldData.field_labels('removeallafter')='Remove all after'; //jshint ignore:line
  getCustomFieldData.field_tips('removeallafter')='Enter a regular expression to match'; //jshint ignore:line

function OnGetNewName(getNewNameData){
  var removeallafter=getNewNameData.custom.removeallafter;
  var name=getNewNameData.newname_stem;
  var re;
  var matches;
  if (name!=''){
    if (removeallafter){
      re=new RegExp(removeallafter,'i');
      if (matches){
  return name+getNewNameData.newname_ext;
1 Like

thanks for the code
i wanted to remove "from" written character, not "after" it. like i wanna remove from "...eps..." and i type eps, but it keeps the written characters. what should i do?

The built-in Find and Replace is probably all you need.


Awesome script, thank you! Would it be possible to edit the script to include in the removal the matched text?

Many thanks, this is very useful. I would like to know more on how to:

  1. remove all after the 8th letter in the file names, what would be the input to key in?
  2. convert this into "Remove all before"


@srmalis @iieeann The standard RegEx mode will be sufficient:



How to use buttons and scripts from this forum