[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Losing '_b00jdlb8_default' from a files name?



Mark Carroll grabbed a keyboard and wrote:
> David Guntner <david@guntner.com> writes:
> 
>> Mark Carroll grabbed a keyboard and wrote:
> (snip)
>>> for i in *_????????_default\.m??
>>> do mv "$i" "`echo $i | sed 's/.\{17\}\(.\{4\}\)$/\1/'`"
>>> done
>>
>> Ooh, yea, that looks like it would do it, way better than what I came up
>> with if it doesn't require a specific number of fields.  I'm a little
>> vague on my sed syntax, though.  Could you break that down and explain
>> how that's doing what it does?
> 
> Sure. First, the \ in the first line is superfluous. (-:
> 
> The sed replacement is:
> 
> - 17 characters, the count marked within \{ \}
> - 4 characters is capture group 1, marked within \( \)
> - the end of the string, marked with $
> replace with
> - group 1, marked with \1
> 
> So,
> - the 17 are for the _????????_default
> - group 1 is for .m4a
> to replace _????????_default.m4a with .mp4
> 
> Using the $ to anchor to the end of the string is the key here. I can be
> sloppy about what characters match because the glob in the for loop did
> my matching for me.

Very cool, and slick, too. :-)  Thanks!

       --Dave



Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


Reply to: