Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finding YYYYMMDD_YYYYMMDD files with regexp

1 view
Skip to first unread message

Uwe Ziegenhagen

unread,
Nov 20, 2009, 3:14:06 PM11/20/09
to
Hi,

I have several hundred files here which accidently got renamed after the
following pattern:


YYYYMMDD_YYYYMMDD-something


where the first date does not match the second date. How can I get the
file which follow this pattern?


Thanks from Germany,


Uwe

Al Fansome

unread,
Nov 20, 2009, 4:10:31 PM11/20/09
to
This doesn't do an sanity checking on whether the dates make sense, but
it will match your pattern

ls | % {if ($_.name -match "\d{8}_\d{8}-.+") {$_}}

You can change that last {$_} to {$_.name} if you just want this to
print out the file names.

Uwe Ziegenhagen

unread,
Nov 23, 2009, 2:01:35 PM11/23/09
to
Al Fansome schrieb:

> This doesn't do an sanity checking on whether the dates make sense, but
> it will match your pattern
>
> ls | % {if ($_.name -match "\d{8}_\d{8}-.+") {$_}}
>

Thanks very much!

Uwe

0 new messages