# Can DOpus automatically handle/change illegal characters?

**URL:** <https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980>\
**Category:** Help & Support\
**Created:** [February 3, 2007, 5:56am UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980 "2007-02-03T05:56:23Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmkeuning](https://resource.dopus.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jmkeuning](https://resource.dopus.com/u/jmkeuning)\
**Post date:** [February 3, 2007, 5:56am UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/1 "2007-02-03T05:56:23Z")

</div>

I do a lot of file renaming via copy and paste. So, I have on the clipboard-

Buns: A Book About Hot Dogs  
   
When I try to rename a folder, the stuff after the colon is pasted, the stuff before is ignored.

Can DOpus automatically change the illegal characters? I have the same issues with question marks.

Thanks

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [February 3, 2007, 10:34am UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/2 "2007-02-03T10:34:27Z")

</div>

CreateFolder FROMCLIPBOARD will create a new folder with the name of what's in the clipboard, with illegal characters converted.

I don't think there's a way to make inline rename do a similar thing, but I agree that it's a good idea.

I've filed a feature request for you suggesting that when someone pastes text while renaming the characters are substituted (but the current system remains in place if someone manually tries to type : or whatever, as getting a \_ would be confusing).

---

<div class="post-metadata">

**Author:** ![jmkeuning](https://resource.dopus.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jmkeuning](https://resource.dopus.com/u/jmkeuning)\
**Post date:** [February 6, 2007, 4:24am UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/3 "2007-02-06T04:24:08Z")

</div>

This is such a n00b question. But what exactly to I do with that code? What I have tried creates a folder called

CreateFolder FROMCLIPBOARD

HA HA!!

---

<div class="post-metadata">

**Author:** ![kenalcock](https://resource.dopus.com/letter_avatar_proxy/v4/letter/k/5e9695/32.png) [@kenalcock](https://resource.dopus.com/u/kenalcock)\
**Post date:** [February 6, 2007, 4:51am UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/4 "2007-02-06T04:51:56Z")

</div>

We are all learning, just in different places and at different paces! 🙂

1. Right-click a toolbar
2. Select Customize
3. Right-click a toolbar
4. Select New - New Button
5. Right-click the new button
6. Select Edit
7. Click the Advanced button
8. Put CreateFolder FROMCLIPBOARD as the command
9. Okay everything and exit Customize mode.

Now when you copy some text to your clipboard, you activate the File Display where you want to create the folder. Then you click the button.

I don't think this will help you rename a folder that already exists, but it will help you create a new one without the special characters.

---

<div class="post-metadata">

**Author:** ![jmkeuning](https://resource.dopus.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jmkeuning](https://resource.dopus.com/u/jmkeuning)\
**Post date:** [February 6, 2007, 4:55am UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/5 "2007-02-06T04:55:38Z")

</div>

Yup! that is doing exactly what it is supposed to.

Amazing.

---

<div class="post-metadata">

**Author:** ![robertcollier4](https://resource.dopus.com/user_avatar/resource.dopus.com/robertcollier4/32/30641_2.png) [@robertcollier4](https://resource.dopus.com/u/robertcollier4)\
**Post date:** [November 4, 2012, 11:47am UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/6 "2012-11-04T11:47:02Z")

</div>

I would like to add my vote that this is a much needed feature - especially in Inline Rename.

Very often - I am inline renaming a file with a name coming from copy-paste usually from the internet - such as a Web Page Title which may have : (colon) or / (slash) characters in it.  
It would be very nice if Dopus would convert them to - (dash).

---

<div class="post-metadata">

**Author:** ![BetterRed](https://resource.dopus.com/letter_avatar_proxy/v4/letter/b/3e96dc/32.png) [@BetterRed](https://resource.dopus.com/u/BetterRed)\
**Post date:** [November 4, 2012, 10:18pm UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/7 "2012-11-04T22:18:44Z")

</div>

[quote="jmkeuning"]I do a lot of file renaming via copy and paste. So, I have on the clipboard-

Buns: A Book About Hot Dogs

When I try to rename a folder, the stuff after the colon is pasted, the stuff before is ignored.

Can DOpus automatically change the illegal characters? I have the same issues with question marks.

Thanks[/quote]  
That's odd - I did an inline folder rename by pasting Buns: A Book About Hot Dogs from the clipboard and I got folder named Buns A Book About Hot Dogs Opus seems to have ignored the colon just as it would have done, I had typed a colon - but it didn't do any cropping around the colon 😕

Developers : Please make any new feature to auto-replace illegal characters optional - preferably opt-in rather than opt-out.

Thanks BR

---

<div class="post-metadata">

**Author:** ![daroc](https://resource.dopus.com/user_avatar/resource.dopus.com/daroc/32/26038_2.png) [@daroc](https://resource.dopus.com/u/daroc)\
**Post date:** [November 5, 2012, 12:10am UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/8 "2012-11-05T00:10:13Z")

</div>

I personally use Ctrl+Shift+V which does:

```auto
Rename TO "{clip}.{ext}" FILEINFO
```

Maybe you could write simple script (like in Autohotkey?) that would replace all illegal characters in the clipboard before executing Rename command.

---

<div class="post-metadata">

**Author:** ![ashmid](https://resource.dopus.com/letter_avatar_proxy/v4/letter/a/e68b1a/32.png) [@ashmid](https://resource.dopus.com/u/ashmid)\
**Post date:** [November 5, 2012, 12:45am UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/9 "2012-11-05T00:45:39Z")

</div>

I also find, as did BetterRed, that illegal chars are automatically eliminated during inline rename. I think this is a wonderful feature. The one thing I would request, though, is that there please be an option to specify what the illegal chars are replaced with. The default seems to be to replace them with an empty string; however, I would much prefer to replace them with underscores.

---

<div class="post-metadata">

**Author:** ![BetterRed](https://resource.dopus.com/letter_avatar_proxy/v4/letter/b/3e96dc/32.png) [@BetterRed](https://resource.dopus.com/u/BetterRed)\
**Post date:** [November 5, 2012, 6:04am UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/10 "2012-11-05T06:04:18Z")

</div>

> [@ashmid](#):
>
> I also find, as did BetterRed, that illegal chars are automatically eliminated during inline rename. I think this is a wonderful feature.

I wasn't going to make any value comments on Opus inline rename, but since ashmid has and to make my position clear - I think this a awful feature.

I would never deliberately type or blindly paste any of the illegal characters into a file or folder name. If I do then I have made a mistake which I would expect to be given the opportunity of correcting.

What I would like is the same error bubble I get in Windows Explorer

`A folder or file name can't contain any of the following characters
\ / : * ? " < > |`

Ideally, I'd like the error bubble when I leave the edit field rather than as I type.

As a consequence of this wonderful/awful feature I have to manually eyeball every inline rename before I hit enter  
If I type A\<ERICA I get AERICA, if I don't check it or hit enter to soon the folder/file will be found just before AEROPLANE rather than just after AMEN.

What annoys me is that I get no indication of my mistake, its just tossed into the bit bucket ... arrogantly. If I type a wrong value show some sort of error somewhere, give me the change to correct my mistakes - don't just ignore it and compound the error. I would have thought that would be taught in UI Design 101 - Lesson 1 😒

Being different from Windows is fine if its better, but if its not then why bother, and if its worse, as in this this case, then...

But I do like the inline rename options 🙂

BR

---

<div class="post-metadata">

**Author:** ![daroc](https://resource.dopus.com/user_avatar/resource.dopus.com/daroc/32/26038_2.png) [@daroc](https://resource.dopus.com/u/daroc)\
**Post date:** [November 5, 2012, 10:40pm UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/11 "2012-11-05T22:40:31Z")

</div>

It's much quicker to just replace incorrect strings than see message  
"hey! you typed or pasted incorrect character into the file name!"  
You correct one error, hit enter and get another error saying you forgot about another illegal character etc...

I find current behavior more user-friendly.

Of course, there might be an option to choose if you want to replace incorrect characters automatically or see error message but I wouldn't set it to the highest priority.

---

<div class="post-metadata">

**Author:** ![robertcollier4](https://resource.dopus.com/user_avatar/resource.dopus.com/robertcollier4/32/30641_2.png) [@robertcollier4](https://resource.dopus.com/u/robertcollier4)\
**Post date:** [November 6, 2012, 1:39pm UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/12 "2012-11-06T13:39:21Z")

</div>

> [@ashmid](#):
>
> I also find, as did BetterRed, that illegal chars are automatically eliminated during inline rename. I think this is a wonderful feature. The one thing I would request, though, is that there please be an option to specify what the illegal chars are replaced with. The default seems to be to replace them with an empty string; however, I would much prefer to replace them with underscores.

1. When creating a folder with ":" - it will convert the ":" to a blank space. However when doing inline rename with a ':" - all the text before the ":" will disappear. This is odd behavior since I often name text files from a URL Webpage Title from the Internet (the file has text in it that I have copied from an Internet webpage with that title or heading).
2. When doing inline rename or create folder with a "/" - it will interpret the "/" as you want to create a directory structure - and it will create a directory and place the file-folder inside of the directory name to the left of the "/". Although I see the logic behind this - it would be nice if there was an option, since I have many filenames that come from URL Webpage Titles that have "/" in them - for example the word "and/or".
3. When copy-pasting a title with "?" in it to "Create Folder" - it will remove the "?" automatically. However when copy-pasting a title with "?" during inline-rename - it will throw an error message. Again inconsistent behavior.

These are three main use cases I have problems with - ":" and "/" and "?" since these are often found in Titles.

I understand that people have different usage cases. It would be nice if there were 2 preferences, specifically:

1. [CHECKBOX] Automatically convert ':' character to '-' during inline rename.
2. [CHECKBOX] Automatically convert '/' character to '-' during inline rename.
3. [CHECKBOX] Automatically remove '?' character during inline rename.

---

<div class="post-metadata">

**Author:** ![daroc](https://resource.dopus.com/user_avatar/resource.dopus.com/daroc/32/26038_2.png) [@daroc](https://resource.dopus.com/u/daroc)\
**Post date:** [November 6, 2012, 6:21pm UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/13 "2012-11-06T18:21:15Z")

</div>

For me it always removes : and ? from file name. What I do is press F2 (rename inline) and paste name from clipboard which is something like "abc:def" or "abc?def" but it always removes illegal characters. Also, if I type : or ? to the file name after pressing F2, it removes these characters when typing.  
Could you provide more detailed steps?

---

<div class="post-metadata">

**Author:** ![Jon](https://resource.dopus.com/user_avatar/resource.dopus.com/jon/32/12713_2.png) [@Jon](https://resource.dopus.com/u/Jon)\
**Post date:** [November 6, 2012, 6:31pm UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/14 "2012-11-06T18:31:37Z")

</div>

Non-filename characters will be stripped unless they form a valid path string. So "C:\blah.txt" would be ok where as "[http://blah.com](http://blah.com)" would not. This is a feature, not a bug.

---

<div class="post-metadata">

**Author:** ![daroc](https://resource.dopus.com/user_avatar/resource.dopus.com/daroc/32/26038_2.png) [@daroc](https://resource.dopus.com/u/daroc)\
**Post date:** [November 6, 2012, 8:59pm UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/15 "2012-11-06T20:59:32Z")

</div>

Personally I often use slashes in file names to quickly move and/or rename files. It's easier than opening apt folder and dropping file on it.

---

<div class="post-metadata">

**Author:** ![robertcollier4](https://resource.dopus.com/user_avatar/resource.dopus.com/robertcollier4/32/30641_2.png) [@robertcollier4](https://resource.dopus.com/u/robertcollier4)\
**Post date:** [November 9, 2012, 5:43pm UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/16 "2012-11-09T17:43:26Z")

</div>

Okay, I solved this with an AutoHotKey script as per daroc's recommendation. For anyone else who is interested:

```auto
;Paste clipboard with illegal filename characters stripped
^!+v::                            
	strippedillegals = %ClipBoard%
	strippedillegals := RegExReplace(strippedillegals,"[\\/:*?""<>|]")
	ClipBoard = %strippedillegals%
	Send,^v
	VarSetCapacity(strippedillegals, 0) ; Free memory
Return
```

---

<div class="post-metadata">

**Author:** ![robertcollier4](https://resource.dopus.com/user_avatar/resource.dopus.com/robertcollier4/32/30641_2.png) [@robertcollier4](https://resource.dopus.com/u/robertcollier4)\
**Post date:** [November 11, 2012, 2:51pm UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/17 "2012-11-11T14:51:29Z")

</div>

Here is a full solution that causes Ctrl+Shift+R to automatically rename a file from the clipboard contents. Have also modified the script to handle newlines and convert certain characters to "-"

In AutoHotKey:

`^+r::
	StringReplace, clipboard, clipboard, `r`n, %A_Space%, All
	StringReplace, clipboard, clipboard, /, -, All
	StringReplace, clipboard, clipboard, :, -, All
	StringReplace, clipboard, clipboard, », -, All
	clipboard := RegExReplace(clipboard,"[\*?""<>|]")
	Send,^!+#r
Return`

In Dopus:  
HotKey Win+Ctrl+Shift+Alt+R set to:  
Rename TO "{clip}.{ext}" FILEINFO

---

<div class="post-metadata">

**Author:** ![robertcollier4](https://resource.dopus.com/user_avatar/resource.dopus.com/robertcollier4/32/30641_2.png) [@robertcollier4](https://resource.dopus.com/u/robertcollier4)\
**Post date:** [November 15, 2012, 5:24am UTC](https://resource.dopus.com/t/can-dopus-automatically-handle-change-illegal-characters/2980/18 "2012-11-15T05:24:20Z")

</div>

Better version updated. Uses DopusRT. Performs rename from clipboard with filename allowed characters being only alphanumeric, space, dash, parenthesis, comma, period.

```auto
^+r::
IfWinActive, ahk_class dopus.lister
{
	StringReplace, filename, clipboard, `r`n, %A_Space%, All ;replace newlines with spaces
	StringReplace, filename, filename, /, -, All
	StringReplace, filename, filename, \, -, All
	StringReplace, filename, filename, :, -, All
	StringReplace, filename, filename, », -, All
	StringReplace, filename, filename, ~, -, All
	filename := RegExReplace(filename, "-+", "-") ;remove double dash
	filename := RegExReplace(filename,"[^[:alnum:][:space:]-(),.]") ;remove all but desired filename characters
	filename := RegExReplace(filename, "[[:blank:]]+", " ") ;remove double space
	filename = %filename% ;autotrim leading and trailing whitespaces
	StringLeft, filename, filename, 64
	;MsgBox %filename%
	Run, "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /cmd Rename TO "%filename%.{ext}" FILEINFO
	VarSetCapacity(filename, 0) ; Free memory
}
Return
```
