ayoisaiah / f2

F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely. Written in Go!
https://f2.freshman.tech
MIT License
866 stars 38 forks source link

Concatenate digits after a token number? #58

Closed joeldebruijn closed 10 months ago

joeldebruijn commented 10 months ago

I'm renaming with tokens and want to add numbers, for example:

f2 -f '(\d{4})-(\d{2})-(\d{2}) (\d{4})_(\d{8})(\d{4}).gpx' -r '$5-$600.gpx'

Use case:

Problem I think: Token nr 6 + characters 00 actually looks like token number 600.

Is there a way to concatenate 00 after a token number?

msalbrain commented 10 months ago

If this is still available, Would like to try it out

msalbrain commented 10 months ago

@joeldebruijn after checking the docs I don't think that is possible. The best I got is adding a space or hyphen:


f2 -f '(\d{4})-(\d{2})-(\d{2}) (\d{4})__(\d{8})_(\d{4}).gpx' -r '$5-$6 00.gpx'

but I think having a simple character that escapes the $6 will solve the problem like -r '$5-$6/00.gpx'.

ayoisaiah commented 10 months ago

@joeldebruijn @msalbrain

This should do what you want:

f2 -f '(\d{4})-(\d{2})-(\d{2})__(\d{8})_(\d{4}).gpx' -r '$4-$5 00.gpx' -f ' '

image

Of course, you can use a different character instead of a space.

See: https://github.com/ayoisaiah/f2/wiki/F2-tutorial#chaining-renaming-operations

joeldebruijn commented 10 months ago

Subsequently adding a character and removing it, neat! And lots of characters to choose from with small/zero chance being there in any other way. Thnx!