Author: post
Date: 2010-08-08 16:04:56 +0200 (Sun, 08 Aug 2010)
New Revision: 3484
Modified:
trunk/src/filename.c
trunk/src/rs-batch.c
Log:
Update batch export functionality:
1) "%p" will insert the path of file to be converted, so "%p/exported/%f_%2c"
will now export to /exported/ in orginal path.
2) If a directory is not existing, we attempt to create it, so you can use
"%d/%f_%2c" to export to a folder with the date of each exported image.
3) Report errors to status bar and abort if an error occurs during batch
processing.
Modified: trunk/src/filename.c
===================================================================
--- trunk/src/filename.c 2010-08-04 20:11:25 UTC (rev 3483)
+++ trunk/src/filename.c 2010-08-08 14:04:56 UTC (rev 3484)
@@ -46,6 +46,7 @@
* %s = setting (A,B or C)
* %d = date (will have to wait until read from exif)
* %t = time (will have to wait until read from exif)
+ * %p = path of raw file
*/
gchar temp[1024];
@@ -57,12 +58,14 @@
gboolean file_exists = FALSE;
gint i = 1;
gchar *basename;
+ gchar *path;
RSMetadata *metadata = rs_metadata_new_from_file(filename);
if (filename == NULL) return NULL;
if (in == NULL) return NULL;
basename = g_path_get_basename(filename);
+ path = g_path_get_dirname(filename);
output = g_strrstr(basename, ".");
/* Prepare time/date */
@@ -179,6 +182,13 @@
g_free(result);
break;
}
+ case 'p':
+ {
+ strcpy(&temp[m], path);
+ m += strlen(path);
+ n += 2;
+ break;
+ }
default:
temp[m++] = in[n];
temp[m++] = in[n+1];
@@ -213,6 +223,7 @@
g_free(basename);
g_free(tm);
+ g_free(path);
g_object_unref(metadata);
return output;
@@ -277,10 +288,18 @@
};
static void
+add_p(GtkMenuItem *menuitem, GtkBin *combo)
+{
+ GtkWidget *entry = gtk_bin_get_child(combo);
+ gtk_entry_append_text(GTK_ENTRY(entry), "%p");
+};
+
+static void
filename_add_clicked(GtkButton *button, gpointer user_data)
{
gui_menu_popup(GTK_WIDGET(button), user_data,
_("%f - Original filename"), add_f,
+ _("%p - Path of original file"), add_p,
_("%2c - Incremental counter"), add_c,
_("%s - Setting id (A, B or C)"), add_s,
_("%d - Date from EXIF (YYYY-MM-DD)"), add_d,
Modified: trunk/src/rs-batch.c
===================================================================
--- trunk/src/rs-batch.c 2010-08-04 20:11:25 UTC (rev 3483)
+++ trunk/src/rs-batch.c 2010-08-08 14:04:56 UTC (rev 3484)
@@ -378,7 +378,7 @@
GdkPixbuf *pixbuf = NULL;
gint width = -1, height = -1;
gdouble scale = -1.0;
- gchar *parsed_filename, *basename;
+ gchar *parsed_filename, *basename, *parsed_dir;
GString *filename;
GString *status = g_string_new(NULL);
GtkWidget *window;
@@ -510,12 +510,27 @@
rs_cache_load(photo);
/* Build new filename */
- filename = g_string_new(queue->directory);
- g_string_append(filename, G_DIR_SEPARATOR_S);
- g_string_append(filename, queue->filename);
+ if (NULL == g_strrstr(queue->filename, "%p"))
+ {
+ filename = g_string_new(queue->directory);
+ g_string_append(filename, G_DIR_SEPARATOR_S);
+ g_string_append(filename, queue->filename);
+ }
+ else
+ filename = g_string_new(queue->filename);
+
g_string_append(filename, ".");
g_string_append(filename,
rs_output_get_extension(queue->output));
parsed_filename = filename_parse(filename->str,
filename_in, setting_id);
+
+ /* Create directory, if it doesn't exist */
+ parsed_dir = g_path_get_dirname(parsed_filename);
+ if (FALSE == g_file_test(parsed_dir, G_FILE_TEST_EXISTS
| G_FILE_TEST_IS_DIR))
+ if (g_mkdir_with_parents(parsed_dir, 0x1ff))
+ {
+ gui_status_notify(_("Could not create
output directory."));
+ break;
+ }
/* Set input profile */
RSDcpFile *dcp_profile =
rs_photo_get_dcp_profile(photo);
@@ -641,6 +656,11 @@
gboolean exported = rs_output_execute(queue->output,
fend);
if (exported)
rs_store_set_flags(NULL, photo->filename, NULL,
NULL, &exported);
+ else
+ {
+ gui_status_notify(_("Could not export photo."));
+ break;
+ }
g_free(parsed_filename);
g_string_free(filename, TRUE);
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit