can I insert the modified (curr) date at a certain position?

A swapping-ground for Regular Expression syntax

can I insert the modified (curr) date at a certain position?

Postby torstenK » Fri Mar 17, 2017 11:47 pm

hello all :)

sorry for the presumably 'simple' question, but am quite new to BUR and need at this certain point the 'heureka' moment . ...

file names look like this:

TEUROMED_24hours 0123 45.png
its a huge archive of earthquake maps and currently stored in daily folders together with other geophysical data of the individual day.
now I want to insert the modified date (and would also like to know about the other 'date' types as well) at a certain position

new file name should look like

TEUROMED_24hours 2017-03-17 0123 45.png

can I do this with regular expression and how can I ? :?:

thanks in advance ... saves me hours of manually renaming ----
torstenK
 
Posts: 4
Joined: Fri Mar 17, 2017 11:35 pm

Re: can I insert the modified (curr) date at a certain position?

Postby KenP » Sat Mar 18, 2017 12:37 am

I don't think you can do it in 1 operation with regex but you could do it in 2 renaming operations.

The regex below is based on the assumption that the digits at the end of the file name (in the example 0123 45) is always 4 digits space 2 digits, if this is not the case please post more information about the number formats used.

1.
Auto Date (5)
Mode: Prefix
Type: Modified (Curr)
Fmt: Custom
Custom: %Y-%m-%d (There's a space after the %d)

Rename
Reset - (Or deselect or reset Auto Date.)

2.
RegEx (1)
Match: ^(\d{4}-\d{2}-\d{2} )(.*)(\d{4} \d{2})$
Replace: \2\1\3
KenP
 
Posts: 199
Joined: Sat Jul 30, 2016 11:25 am

Re: can I insert the modified (curr) date at a certain position?

Postby Admin » Sat Mar 18, 2017 12:58 am

Hi, if you need to do this in one pass, you can do it creating a Javascript function (special (14)).
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: can I insert the modified (curr) date at a certain position?

Postby torstenK » Sat Mar 18, 2017 1:55 am

wow, thanks for the fast reply .... :)

uhm ... will check out your cryptics (I understand the concept though and try to figure out the 'mechanism' in the lines you posted, thanks a lot for that ! ) later.
yes there are differences in the digits.

the maps do exist in 8 different file 'types'
4 for the european mediterranean area and
4 for the global area

the differences are expressed as part of the filename and the sytax is
area_period hhmm count
exapmples:

TEUROMED_24hours 1245 23.png (24hour plot, 1245 download, 23 events)
TWORLD_1week 0723 151.png

so in principle the three digit counter can affect me in the 24hour plots (rare but happening especially when swarm quake occur at Europe)
and regularly occors at the 1 week or 2 week plots. Also the 48hours plots are involved.

but I think I am able to manually create split sets with copy comand definitions and rename each set with a different expression.

so, it would be very kind if you could reveal the trick to me where I can switch to the three digit case when neccessary.

until you posted I was somehow convinced it were possible to treat these counter digits as a group and these could be treated in expressions as \3
assuming TWORLD_24hours were \1 then the insert of the modified date, then the hours as \2 and the counter as group #3 ( \3 )

Intuitively I tried \1 %Y-%m-%d \2 \3 after I defined match: (.*) \d\d\d\d (.*) but the variable from the auto date option box didn't work out as expected ....

(still learning how to do the thing right ...)

if you want to see the data per http protocol - I've put it on a hard drive and made it accessible via
ftp:\\External User:climate change isreal@t0rst3nk3rsten.ddnss.de:21

the purpose is to offer geophysical data in one place from 62 different monitors - from solar activity down into ionosphere, magnetosphere atmospshere and lithosphere, otherwise you run from pontius to pilatus to get the datascape of 1 day ....

currently I extract the data from the daily archive structure and put it into a directory per observed instrument ... therefore I need the date inserted in the existing file names. Thanks a lot for tips and assistance!
torstenK
 
Posts: 4
Joined: Fri Mar 17, 2017 11:35 pm

Re: can I insert the modified (curr) date at a certain position?

Postby torstenK » Sat Mar 18, 2017 2:00 am

uhm ... oups the password in the ftp adress needs a correction
replace between colon (:) and @ with 'climate change is real'
the difference is the blank between 'is' and 'real'
torstenK
 
Posts: 4
Joined: Fri Mar 17, 2017 11:35 pm

Re: can I insert the modified (curr) date at a certain position?

Postby torstenK » Sat Mar 18, 2017 2:32 am

so, thanks for the translation into the code for RegEx

it works perfectly well and meanwhile I even found the switch for the 3 digit variant ... :D ...

I even understand how it works in this case ..... (though the circumflex causes me scratchin my head ...) ... ;-)
still hyroglyphic to me ... will look up the definitions ... ;-)
torstenK
 
Posts: 4
Joined: Fri Mar 17, 2017 11:35 pm

Re: can I insert the modified (curr) date at a certain position?

Postby KenP » Sat Mar 18, 2017 11:07 am

This should match file names where the last chars are either 2 or 3 digits, the Replace characters remain as before.

Match: ^(\d{4}-\d{2}-\d{2} )(.*)((\d{4}) (\d{3}|\d{2}))$

The | means or, so the last part of the regex (\d{3}|\d{2}) will match 3 digits or 2 digits :wink:
KenP
 
Posts: 199
Joined: Sat Jul 30, 2016 11:25 am


Return to Regular Expressions