Naming Capture File from content received?
Serial and TCP terminal for engineering and debugging
Brought to you by:
crun
I use Realterm to capture characters in to a CSV file, overwriting the same file each time.
But is there a way to direct the characters into a different file each time, say by taking the filename from the first transmitted line? If this isn't impossible, any ideas gratefully received.
Yes. In the current development versions (3.0.0.29+) you can automatically split files, using a timestamp named file.
<filename>_2016-06-07_1853-33.<ext>
Try it and report back your results.</ext></filename>
see http://realterm.sourceforge.net/#Capture
"Restarting, AutoName, and Long Captures
Some users leave Realterm capturing for long periods. Files can grow very large, or be unwieldy to find data in.
Restart and AutoName (V3.0.0.28+), lets Realterm begin a new file, after N secs or bytes, with the DateTime appended to the filename. Previously this was done via a batch file.
eg to capture temperature data, with a new data file automatically created every day, and the datetime suffix in filename.....
realterm capsecs=86400 capautoname=1 capfile="c:\temp\temperature_log.txt" capture=3
"
Thansk for the response. I was thinking of a specific/controlled filename, rather than a date/timestamp type, so I knew what the transfer would be saved as on the target PC. Is that possible?
OK you need to explain the use case for this.
At first sight, asking the filename from the first data line seems rather indeterminate and not-useful-to-anyone-else.
I did consider simple sequentially numbered files as an option.
<filename>_001.<ext>
But this begs the question of what number do you start at?
Is it 001 everytime the "start capture" is pressed, overwriting its predecessors?
or is it 001 everytime RT is started?
or does it need a UI control to set the start number?</ext></filename>
Oh, of course you can use a capture post-process batch file to rename the files for you....
Probably using the ever handy SED to extract the first line to use as a name.
So, yes it currently can do what you want....
BTW what are you doing?
OK, thanks for the suggestions. I agree that what I'm doing is unusual; I didn't expect this as a standard option.
What I'm doing is taking data stored on ancient Psion type organisers (pre-Windows, obsoleted late 1990s) and wishing to transfer it, via RS232, to a new file on a Win 7 PC. The filename is a specific format (transmitted at start of RS232 string) and I want to preserve this. Less PC experienced people than me need to do this, hence seeking something as automatic as possible.
I can currently do this, via the (equally ancient) PsiWin comms software, which due to its age and drivers, must run on a Win 7 PC emulating Win XP 32 bit via MS's free XP Mode emulator. This does work, but is ineligant and raises the question of moving to post Win 7 PCs, when I guess XP 32bit emulators won't be available.
I realise this is all about obsolescence, but if you have any fixes or workarounds, they'd be appreciated.
Well I think that you can use SED in a batch file to extract the filename from the start of the file, and use it to rename the files.
But how does Realterm get different files?
Do you ask for each file?
Or do you are for everything, and it comes out in one giant stream?
I manually start & stop capture of text for each file transfer. Any pointers or links to SED use for auto renaming would be great.
Just google what you want to do, there are lots of pages about renaming files based on the first line.
A lot will be for linux, but UnxUtils has most of the utils for dos. You can also get bash for dos, but mostly I just use batch files and unix utilities.
Having made such a batch file, Realterm can run it as post process after capture. Or you can automate the whole process from a batch file that launches Realterm to capture the serial.
HEAD can get the first line(s) of a file
SED can get select all sorts of things including the first line.
One issue to consider, is that the first line might contain invalid chars for a filename. SED or TR could be used to fix these.
Ticket moved from /p/realterm/support-requests/29/
Can't be converted:
V3.0.0.32 can sequentially autoname capture files, if that is useful for you to test
file_1
file_2
etc