Moving a file through script
I've written a C# script that looks like this (using VS10):
dynamic app = Activator.CreateInstance(Type.GetTypeFromProgID("PhaseOneMediaPro.Application"));
dynamic catalog = app.ActiveCatalog;
foreach (dynamic item in catalog.Selection)
{
string previousPath = item.Path;
item.Path = previousPath;
}
The script does nothing useful, it's just to demonstrate the problem, which is that setting item.Path always throws a COMException (E_FAIL) even if it's just being set to its current value. My goal is to move files to different folders based on their attributes. Is this possible? Is setting the Path property the wrong way?
Thanks!
-Josh
dynamic app = Activator.CreateInstance(Type.GetTypeFromProgID("PhaseOneMediaPro.Application"));
dynamic catalog = app.ActiveCatalog;
foreach (dynamic item in catalog.Selection)
{
string previousPath = item.Path;
item.Path = previousPath;
}
The script does nothing useful, it's just to demonstrate the problem, which is that setting item.Path always throws a COMException (E_FAIL) even if it's just being set to its current value. My goal is to move files to different folders based on their attributes. Is this possible? Is setting the Path property the wrong way?
Thanks!
-Josh
0
-
Josh,
From my limited scripting skills - and I don't know if there's been any change from iView/xMedia to MediaPro - I'm not aware of any method for doing this. There is a method for "moving" files but the parameter for this is the new position in the catalogue i.e. it's for sorting files within a catalogue.
The only way I can see that it's possible is to use the Delete method for each item and then to Import them from the new location. If you have a large number of images then this could take time. Plus if you have any meta-data not embedded in the file then it wouldn't move with the file. There isn't a method for reset the path for a file either.
I have an XSL script I developed to move all files with label 9 - my rejects - to a different directory. However I gave up trying to do this with a VB script and resorted to using XSL via the XML export. It writes out the required DOS commands i.e. an XCOPY followed by a delete and I then run it as a batch file. I don't need these images in a catalogue as they end up getting deleted whenever I do some housekeeping.
Ian0 -
Thanks. I decided to work around the issue by writing a script that would select the files I wanted to move, then prompt me to move them through the UI (repeating this sequence for each new folder I wanted to move files into).
-Josh0
Post is closed for comments.
Comments
2 comments