# Filename Cleanup Regex

**URL:** https://resource.dopus.com/t/filename-cleanup-regex/2187
**Category:** Help & Support
**Created:** [July 12, 2006, 8:34pm UTC](https://resource.dopus.com/t/filename-cleanup-regex/2187 "2006-07-12T20:34:07Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![denyerec](https://resource.dopus.com/letter_avatar_proxy/v4/letter/d/6de8d8/32.png) [@denyerec](https://resource.dopus.com/u/denyerec)
#### Post date: [July 12, 2006, 8:34pm UTC](https://resource.dopus.com/t/filename-cleanup-regex/2187/1 "2006-07-12T20:34:07Z")

</div>

I've searched these forums quite hard looking for the solution to the following problem, and I'm close but with no cigar. I've hacked together a few solutions from other people but haven't really gotten to my goal.

What I would like to achieve is something as so:

1- Strip periods from filename  
2- strip underscores from filename  
3- convert filename to Title Case  
4- Insert periods between numbers and the letter V or v  
5- Convert all instances of a hyphen - into a hyphen flanked by a space on either side.

This would convert the following:

FILE.NAME.V.1.2.3-Temp.rar

into:

File Name V1.2.3 - Temp.rar

(Note: the above is the ideal output. V.1.2.3 is acceptable but if it can be worked out that would be lovely)

Doing this to a selection of files is a luxury, being able to do it to just the selected file I will be happy with.

Included is the code for the 2-button combo I have so far come up with. It sometimes works, but the double-space removing FINDREP fails if there are no instances of a double space. If I could have it fail quietly, that would also be OK.

`<xml>
<button>
	<guid>{417C2F43-62E1-4318-BA99-C354D2D63F0F}</guid>
	<label>Strip periods</label>
	<icon1>84</icon1>
	<button>
		<guid>{417C2F43-62E1-4318-BA99-C354D2D63F0F}</guid>
		<label>Strip periods</label>
		<tip>Strips periods between alphabet characters only</tip>
		<icon1>84</icon1>
		<function>
			<instruction>rename PATTERN="." TO=" " FINDREP CASE=Allwords</instruction>
			<instruction>rename PATTERN="-" TO=" - " FINDREP</instruction>
			<instruction>rename PATTERN=" " TO " " FINDREP</instruction>
			<instruction>rename PATTERN=" " TO " " FINDREP</instruction>
			<instruction>@nodeselect</instruction>
		</function>
	</button>
	<button>
		<guid>{F5A5F1ED-8165-4127-AFA7-3E6C28046D1D}</guid>
		<label>Number Spaces to Dots</label>
		<icon1>16</icon1>
		<function>
			<instruction>rename PATTERN="(.*[Vv0-9]) ([0-9].*)" TO="\1.\2" REGEXP</instruction>
			<instruction>rename PATTERN="(.*[Vv0-9]) ([0-9].*)" TO="\1.\2" REGEXP</instruction>
			<instruction>@nodeselect</instruction>
		</function>
	</button>
</button>
`

Thanks in advance if any Einstein out there can crack it!

---

_[View the full topic](https://resource.dopus.com/t/filename-cleanup-regex/2187)._
