Dynamically create new folder on the fly?
in
Programming Questions
•
2 years ago
I would like to dynamically create a folder on the fly using Processing that resides in the same folder as the application. I am working on a time-lapse application that is saving a series of images.
This is what I am currently working with:
import processing.video.*;
Capture cam;
void setup() {
size(800, 600);
// If no device is specified, will just use the default.
cam = new Capture(this, 800, 600);
background(0,0,0);
frameRate(5);
}
int i = 1;
int framesBetweenShots = 20;
void draw(){
i++;
int d = day(); // Values from 1 - 31
int m = month(); // Values from 1 - 12
int y = year(); // 2003, 2004, 2005, etc.
int s = second(); // Values from 0 - 59
int mi = minute(); // Values from 0 - 59
int h = hour(); // Values from 0 - 23
//String s = String.valueOf(d);
if (cam.available() == true) {
cam.read();
image(cam, 0, 0);
}
String monthString = "";
String dayString = "";
String hourString = "";
String minString = "";
String secString = "";
if(m<10){
monthString = "0"+m;
}else{
monthString = ""+m;
}
if(d<10){
dayString = "0"+d;
}else{
dayString = ""+d;
}
if(s<10){
secString = "0"+s;
}else{
secString = ""+s;
}
if(mi<10){
minString = "0"+mi;
}else{
minString = ""+mi;
}
if(h<10){
hourString = "0"+h;
}else{
hourString = ""+h;
}
if( (i%framesBetweenShots) == 0){
save((y+"-"+monthString+"-"+dayString+"-"+hourString+"-"+minString+"-"+secString+".jpg"));
}
}
At the end, I am looking for something like:
save((y+"-"+monthString+"-"+dayString+"-"+hourString+"-"+minString+"-"+secString+"\00001.jpg")); // obv that last "00001" would be sequenced...
Any ideas would be very appreciated. Thanks.
- Eric
This is what I am currently working with:
import processing.video.*;
Capture cam;
void setup() {
size(800, 600);
// If no device is specified, will just use the default.
cam = new Capture(this, 800, 600);
background(0,0,0);
frameRate(5);
}
int i = 1;
int framesBetweenShots = 20;
void draw(){
i++;
int d = day(); // Values from 1 - 31
int m = month(); // Values from 1 - 12
int y = year(); // 2003, 2004, 2005, etc.
int s = second(); // Values from 0 - 59
int mi = minute(); // Values from 0 - 59
int h = hour(); // Values from 0 - 23
//String s = String.valueOf(d);
if (cam.available() == true) {
cam.read();
image(cam, 0, 0);
}
String monthString = "";
String dayString = "";
String hourString = "";
String minString = "";
String secString = "";
if(m<10){
monthString = "0"+m;
}else{
monthString = ""+m;
}
if(d<10){
dayString = "0"+d;
}else{
dayString = ""+d;
}
if(s<10){
secString = "0"+s;
}else{
secString = ""+s;
}
if(mi<10){
minString = "0"+mi;
}else{
minString = ""+mi;
}
if(h<10){
hourString = "0"+h;
}else{
hourString = ""+h;
}
if( (i%framesBetweenShots) == 0){
save((y+"-"+monthString+"-"+dayString+"-"+hourString+"-"+minString+"-"+secString+".jpg"));
}
}
At the end, I am looking for something like:
save((y+"-"+monthString+"-"+dayString+"-"+hourString+"-"+minString+"-"+secString+"\00001.jpg")); // obv that last "00001" would be sequenced...
Any ideas would be very appreciated. Thanks.
- Eric
1