fswebcam icon indicating copy to clipboard operation
fswebcam copied to clipboard

Add '-m'/'--mkdir' options to make file path like mkdir -p

Open PaulWay opened this issue 7 years ago • 6 comments

Hi there!

I've added an option and associated code for having fswebcam check and create the components of the path it's writing files to. This is useful for when writing e.g. time lapses into date-named directories, and a new day starts while fswebcam is running.

PaulWay avatar Oct 13 '16 20:10 PaulWay

BTW, I tested this and it worked on new invocation but not when left running and moving into a new day. I'll trace this down.

PaulWay avatar Oct 16 '16 23:10 PaulWay

Hi there! I've tested this and it's now working :-)

PaulWay avatar Oct 19 '16 22:10 PaulWay

I found a minor annoyance where it would say it was creating a directory with the same name as the filename (although, for reasons I don't entirely understand, it didn't actually create that directory). I fixed that by only looking at the 'directories' part of the path, ignoring the filename at the end. I've tested this and it works.

PaulWay avatar Oct 26 '16 02:10 PaulWay

Hi Paul,

You could do this now with the --exec command, for example:

$ fswebcam --loop 60 --exec "mkdir -p /timelapse/%Y-%m-%d" --png 6 /timelapse/%Y-%m-%d/%H-%M-%S.png

I do like the idea of a flag for it though, seems tidier. I'll try and get a look at it soon.

fsphil avatar Oct 28 '16 11:10 fsphil

On 28/10/16 22:17, Philip Heron wrote:

Hi Paul,

You could do this now with the --exec command, for example:

|$ fswebcam --loop 60 --exec "mkdir -p /timelapse/%Y-%m-%d" --png 6 /timelapse/%Y-%m-%d/%H-%M-%S.png|

I do like the idea of a flag for it though, seems tidier. I'll try and get a look at it soon.

Hey, Phil! Sorry, I was going to write to you this weekend and see if you'd seen the merge request :-)

I did think about that but I think it's so much simpler to have a single option to do that, especially as people may already need the exec call for something else.

Anyway, thanks for getting back to me. Hope this helps!

Have fun,

Paul

PaulWay avatar Oct 29 '16 01:10 PaulWay

Just updated to the current version.

PaulWay avatar Sep 06 '22 01:09 PaulWay