I'm a relatively new user of Mathematica, and currently using it for image processing of multiple tiff movies. I am also exporting tiff files, and I would like a way of naming my exported files after the corresponding input files.
For example I have a folder that contains two movies called Movie1.tiff and Movie2.tiff, I start with this code:
raw = FileNames["*.tif", SystemDialogInput["Directory"]];
movies = Import[#] & /@ raw;
I have created function f
that processes the movies, so in order to export I use the following code, having already specified the directory 'dir':
Do[Export[
dir <> DateString["Time"] <> "timepoint" <> ToString[i] <> "_" <>
".tif", f[#[[i]]]], {i, 1, Length[#]}] & /@ movies;
The reason for including DateString
is because otherwise, the first movie file exports "timepoint1.tiff, timepoint2.tiff, timepoint3.tiff..." etc, but then the second movie exports with the same filenames so it overwrites.
I would be very grateful if someone could suggest a better way of naming the two sets of exported tiff files, preferentially including the filename of the imported files, for example: "Movie1_timepoint1.tiff, "Movie1_timepoint2.tiff..." etc.
Apologies for the long question! Thank you very much in advance!
raw
. $\endgroup$