This section is a repository for useful regular expressions.
ChangeContextValue Action
The following regular expression should allow full access to the path, filename,
and extension when using the ChangeContextValue Action. I’m sure there
is a more efficient way to do it, but this works just fine.
FindRegex: ^((.*\\)(.*)\.(.*))\z
ReplaceRegex:
- $1 = E:\Recorded TV\subdir\another one\Dirty Sexy Money_WJLA-DT_10_10_2007_22_00_01.dvr-ms
- $2 = E:\Recorded TV\subdir\another one\
- $3 = Dirty Sexy Money_WJLA-DT_10_10_2007_22_00_01
- $4 = dvr-ms
So, if you want to change the extension, the ReplaceRegex value would be:
$2$3.wmv
If you want to change the path, the ReplaceRegex would be:
C:\New Path\$3.$4
I don’t suggest using this to change the filename (use the
AdvancedFileRename Action instead). However, if you insist, the
ReplaceRegex would be:
$2$3 (FIXED).$4
Windows Media Center File Name
Format: Title_CHAN_09_30_2006_20_28_02.dvr-ms
Regex: ([^\\]+)_([A-Z]+)_(?=0?(\d+))(\d{2})_(?=0?(\d+))(\d{2})_(?=\d{2}(\d{2}))(\d{4})_(?=0?(\d+))(\d{2})_(?=0?(\d+))(\d{2})_(?=0?(\d+))(\d{2})\.(.+)\z
Back References:
| Back Ref | Description | Value |
|---|
| $1 | The title of the show | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $2 | Channel short name | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $3 | Month (m) | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $4 | Month (mm) | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $5 | Day (d) | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $6 | Day (dd) | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $7 | Year (yy) | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $8 | Year (yyyy) | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $9 | Hour (h) | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $10 | Hour (hh) | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $11 | Minutes (m) | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $12 | Minutes (mm) | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $13 | Seconds (s) | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $14 | Seconds (ss) | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $15 | File Extension | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
| $ | | Title_CHAN_09_30_2006_20_28_02.dvr-ms |
%WM/MediaOriginalBroadcastDateTime%
Format: 2005-01-01
Regex: "(?=\d{2}(\d{2}))(\d{4})-(?=0?(\d+))(\d{2})-(?=0?(\d+))(\d{2})"
Back References:
$1: Year (yy)
$2: Year (yyyy)
$3: Month (m)
$4: Month (mm)
$5: Day (d)
$6: Day (dd)
------------------------
%WM/OriginalReleaseTime%
Format: 2004-01-01T00:00:00.0000000-08:00
Regex: (?=\d{2}(\d{2}))(\d{4})-(?=0?(\d+))(\d{2})-(?=0?(\d+))(\d{2})T(\d{2}):(\d{2}):(\d{2})\.\d+-(\d{2}):(\d{2})
Back References:
$1: Year (yy)
$2: Year (yyyy)
$3: Month (m)
$4: Month (mm)
$5: Day (d)
$6: Day (dd)
$7: Hour (hh)
$8: Minutes (nn)
$9: Seconds (ss)
$10: Milliseconds? (iiiiii)
$11: Time Zone Info (-hh:mm)
$12: Positive or negative time zone difference (-)
$13: Time Zone Hour (hh)
$14: Time Zone Minute (mm)
------------------------
%WM/OriginalReleaseTime%
Format: 2004-01-01T000000.0000000-0800
Regex: (?=\d{2}(\d{2}))(\d{4})-(?=0?(\d+))(\d{2})-(?=0?(\d+))(\d{2})T(\d{2})(\d{2})(\d{2})\.(\d+)(([+-])(\d{2})(\d{2}))
Back References:
$1: Year (yy)
$2: Year (yyyy)
$3: Month (m)
$4: Month (mm)
$5: Day (d)
$6: Day (dd)
$7: Hour (hh)
$8: Minutes (nn)
$9: Seconds (ss)
$10: Milliseconds? (iiiiii)
$11: Time Zone Info (-hh:mm)
$12: Positive or negative time zone difference (-)
$13: Time Zone Hour (hh)
$14: Time Zone Minute (mm)