Script to export Rating to external xmp sidecar

Hi all,
I did this quick script to be able to update Ratings on referenced and online master files. It uses exiftool, so that should be installed. Also, it creates an empty xmp file if none exists, with only the rating in it, or it updates an already existing one with the rating. Aperture 3 doesn't export this by itself.
let me know if it works for you, it comes with no guarantee to work or do anything useful. careful with the line breaks, posting here chops things up a little sometimes.
cheers,
j
--script to create sidecar xmp files for referenced files without having to export masters. parts of the script (finding the file name) are by brett gross
--this script needs exiftool to work. http://www.sno.phy.queensu.ca/~phil/exiftool/ to get it
--it should create an empty xmp file with the aperture's rating, or update an already existing xmp file in place
property p_sql : "/usr/bin/sqlite3 "
property p_exiftool : "usr/bin/exiftool "
global g_libPath
on run
my getLibPath()
--counter for processed images, reset, just in case
set mastercount to 0
tell application "Aperture"
-- rule out any versions other than 3 of aperture, the database has a different structure
set ap_version to version as rich text
if the first character of ap_version is not "3" then
display dialog "This will only work with Aperture 3" buttons {"OK"} default button 1
return
end if
--get selected images
if not (exists selection) then
display dialog "You have to select at least one image" buttons {"OK"} default button 1
return
else
display dialog "You have selected " & (count of selection) & " images." & return & "Continue?" default button 1
end if
set theSel to selection
--run through the selected images
repeat with currentpic from 1 to count of theSel
tell item currentpic of theSel
-- only apply to referenced and online images
if referenced and online then
set mastercount to mastercount + 1
set curID to id
--use sqlite directly to get master file id of version id
--get master file id from version id
set theScript to p_sql & (quoted form of g_libPath) & " \"select masterUuid from RKVersion where uuid='" & curID & "'\""
set masterfileuid to do shell script theScript
--get master path name from master id
set theScript to p_sql & (quoted form of g_libPath) & " \"select imagePath from RKMaster where uuid='" & masterfileuid & "'\""
set imagepath to do shell script theScript
--get volume id from master id
set theScript to p_sql & (quoted form of g_libPath) & " \"select fileVolumeUuid from RKMaster where uuid='" & masterfileuid & "'\""
set volumeuid to do shell script theScript
--get volume name from volume id
set theScript to p_sql & (quoted form of g_libPath) & " \"select name from RKVolume where uuid='" & volumeuid & "'\""
--put them together
set volumename to do shell script theScript
--strips extension, seems to work for files and paths with more than one period
set oldlim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
try --remove last extension only
set contador to text item -1 of imagepath
set noExtension to Unicode text 1 thru -((count of contador) + 2) of imagepath
on error --handle files with no extensions
set noExtension to imagepath
end try
set AppleScript's text item delimiters to oldlim
--create file pointer for editing (if passing on to exiftool, this should not be necessary)
--set xmppath to POSIX file ("/Volumes/" & volumename & "/" & noExtension & ".xmp")
--exiftool version, text passed
set xmppath to ("/Volumes/" & volumename & "/" & noExtension & ".xmp")
end if
--get rating
set rating to value of other tag "MainRating"
set theScript to p_exiftool & (quoted form of xmppath) & " -xmp:Rating=" & rating
do shell script theScript
end tell
end repeat
end tell
end run
-- write xmp sidecar file routine, not being used, because we use exiftool
on writexmpFile(theContents, xmpFileName)
--tell application "Finder"
try
open for access xmpFileName with write permission
set eof of xmpFileName to 0
write (theContents) to xmpFileName starting at eof
close access xmpFileName
on error
try
close access xmpFileName
end try
end try
--end tell
end writexmpFile
--this part copied and adapted from Brett Gross-------------------------------------------------------------------------- --------------------------------
on getLibPath()
tell application "System Events" to set p_libPath to value of property list item "LibraryPath" of property list file ((path to preferences as Unicode text) & "com.apple.aperture.plist")
--add the path to the main Library database to this (added by joost de raeymaeker)
set p_libPath to p_libPath & "/Database/Library.apdb"
if ((offset of "~" in p_libPath) is not 0) then
-- set p_posix to POSIX file p_libPath
set p_script to "/bin/echo $HOME"
set p_homePath to (do shell script p_script)
set p_offset to offset of "~" in p_libPath
set p_path to text (p_offset + 1) thru -1 of p_libPath
set g_libPath to p_homePath & p_path as string
else
set g_libPath to p_libPath as string
end if
end getLibPath
--end brett gross part

Hi all,
I did this quick script to be able to update Ratings on referenced and online master files. It uses exiftool, so that should be installed. Also, it creates an empty xmp file if none exists, with only the rating in it, or it updates an already existing one with the rating. Aperture 3 doesn't export this by itself.
let me know if it works for you, it comes with no guarantee to work or do anything useful. careful with the line breaks, posting here chops things up a little sometimes.
cheers,
j
--script to create sidecar xmp files for referenced files without having to export masters. parts of the script (finding the file name) are by brett gross
--this script needs exiftool to work. http://www.sno.phy.queensu.ca/~phil/exiftool/ to get it
--it should create an empty xmp file with the aperture's rating, or update an already existing xmp file in place
property p_sql : "/usr/bin/sqlite3 "
property p_exiftool : "usr/bin/exiftool "
global g_libPath
on run
my getLibPath()
--counter for processed images, reset, just in case
set mastercount to 0
tell application "Aperture"
-- rule out any versions other than 3 of aperture, the database has a different structure
set ap_version to version as rich text
if the first character of ap_version is not "3" then
display dialog "This will only work with Aperture 3" buttons {"OK"} default button 1
return
end if
--get selected images
if not (exists selection) then
display dialog "You have to select at least one image" buttons {"OK"} default button 1
return
else
display dialog "You have selected " & (count of selection) & " images." & return & "Continue?" default button 1
end if
set theSel to selection
--run through the selected images
repeat with currentpic from 1 to count of theSel
tell item currentpic of theSel
-- only apply to referenced and online images
if referenced and online then
set mastercount to mastercount + 1
set curID to id
--use sqlite directly to get master file id of version id
--get master file id from version id
set theScript to p_sql & (quoted form of g_libPath) & " \"select masterUuid from RKVersion where uuid='" & curID & "'\""
set masterfileuid to do shell script theScript
--get master path name from master id
set theScript to p_sql & (quoted form of g_libPath) & " \"select imagePath from RKMaster where uuid='" & masterfileuid & "'\""
set imagepath to do shell script theScript
--get volume id from master id
set theScript to p_sql & (quoted form of g_libPath) & " \"select fileVolumeUuid from RKMaster where uuid='" & masterfileuid & "'\""
set volumeuid to do shell script theScript
--get volume name from volume id
set theScript to p_sql & (quoted form of g_libPath) & " \"select name from RKVolume where uuid='" & volumeuid & "'\""
--put them together
set volumename to do shell script theScript
--strips extension, seems to work for files and paths with more than one period
set oldlim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
try --remove last extension only
set contador to text item -1 of imagepath
set noExtension to Unicode text 1 thru -((count of contador) + 2) of imagepath
on error --handle files with no extensions
set noExtension to imagepath
end try
set AppleScript's text item delimiters to oldlim
--create file pointer for editing (if passing on to exiftool, this should not be necessary)
--set xmppath to POSIX file ("/Volumes/" & volumename & "/" & noExtension & ".xmp")
--exiftool version, text passed
set xmppath to ("/Volumes/" & volumename & "/" & noExtension & ".xmp")
end if
--get rating
set rating to value of other tag "MainRating"
set theScript to p_exiftool & (quoted form of xmppath) & " -xmp:Rating=" & rating
do shell script theScript
end tell
end repeat
end tell
end run
-- write xmp sidecar file routine, not being used, because we use exiftool
on writexmpFile(theContents, xmpFileName)
--tell application "Finder"
try
open for access xmpFileName with write permission
set eof of xmpFileName to 0
write (theContents) to xmpFileName starting at eof
close access xmpFileName
on error
try
close access xmpFileName
end try
end try
--end tell
end writexmpFile
--this part copied and adapted from Brett Gross-------------------------------------------------------------------------- --------------------------------
on getLibPath()
tell application "System Events" to set p_libPath to value of property list item "LibraryPath" of property list file ((path to preferences as Unicode text) & "com.apple.aperture.plist")
--add the path to the main Library database to this (added by joost de raeymaeker)
set p_libPath to p_libPath & "/Database/Library.apdb"
if ((offset of "~" in p_libPath) is not 0) then
-- set p_posix to POSIX file p_libPath
set p_script to "/bin/echo $HOME"
set p_homePath to (do shell script p_script)
set p_offset to offset of "~" in p_libPath
set p_path to text (p_offset + 1) thru -1 of p_libPath
set g_libPath to p_homePath & p_path as string
else
set g_libPath to p_libPath as string
end if
end getLibPath
--end brett gross part

Similar Messages

  • How to save metadatas in RAW files (and not in external .XMP sidecar file)

    Hello,
    I would like to save metadatas (for example keywords) inside the RAW files, and not in external .XMP sidecar file.
    How to do this in Lightroom ?
    Thanks
    Josh
    PS: is XMP a file format (= .XMP files) or a metadata format that can be embedded either in a .XMP sidecar file or in the RAW itself ?

    MarvinFoster wrote:
    It's a horridly named catalog setting since if you are using DNG you don't have XMP files but it does the same thing, it updates the dng with the catalog settings.
    XMP does not mean XMP FILES per se.
    XMP is a metadata format/standard. so it´s not horrible named but simply missunderstood. 
    http://en.wikipedia.org/wiki/Extensible_Metadata_Platform
    XMP can be used in several file formats such as PDF, JPEG, JPEG 2000, JPEG XR, GIF, PNG, HTML, TIFF, Adobe Illustrator, PSD, MP3, MP4, Audio Video Interleave, WAV, RF64, Audio Interchange File Format, PostScript, Encapsulated PostScript, and proposed for DjVu. In a typical edited JPEG file, XMP information is typically included alongside Exif and IPTC Information Interchange Model data.

  • Always use external XMP sidecar files

    I am coding a utility to convert my existing collection to LR, and I am wondering:
    1) If LR can read XMP sidecar files for images even if the image can internally contain XMP data, e.g. JPG files?
    2) If LR can export XMP data to a sidecar file even if the image can internally contain XMP data, e.g. JPG files?
    Regards
    P.

    the sad part is that if your .jpg are read only (the files only), Lightroom will NOT export the XMP metadata. It would be nice is Lightroom exported XMP sidecar. Better, it would be nice to tell Lightroom to do it every time, like beta 4 was doing (if I'm not mistaken).

  • Write xmp sidecar files without need to export masters - script

    I've written a script to write xmp sidecar files for referenced and online images (the 2 conditions in the script) of the selected images. I looked for a while at system events and other stuff to be able to write the xmp file, but i'm not a programmer, so in the end i chose the long and dirty way to do it.
    This script will export all iptc expanded fields as aperture does (creating basically the same file). It can be easily adjusted to include other tags, even custom ones. I don't know how to get at the adjustments for images, otherwise those could be included as well.
    If anyone has the energy to clean this up and make it faster, feel free to do so. Next, I'm going to try to write a script to do the opposite, import xmp sidecars for imported online and referenced files.
    Here it goes (thanks to Brett Gross for the database part to find the master filename):
    --script to create sidecar xmp files for referenced files without having to export masters. parts of the script (finding the file name) are by brett gross
    property p_sql : "/usr/bin/sqlite3 "
    global g_libPath
    on run
    my getLibPath()
    --counter for processed images, reset, just in case
    set mastercount to 0
    tell application "Aperture"
    if not (exists selection) then
    display dialog "You have to select at least one image" buttons {"OK"} default button 1
    return
    else
    display dialog "You have selected " & (count of selection) & " images." & return & "Continue?" default button 1
    end if
    set theSel to selection
    --run through the selected images
    repeat with currentpic from 1 to count of theSel
    tell item currentpic of theSel
    -- only apply to referenced and online images
    if referenced and online then
    set mastercount to mastercount + 1
    set curID to id
    --find the master file path and name - this part by brett gross, thanks
    set libPOSIX to POSIX path of g_libPath
    set libDBPOSIX to (libPOSIX & "/Aperture.aplib/Library.apdb") as string
    set theScript to p_sql & (quoted form of libDBPOSIX) & " \"select ZFILEUUID from ZRKVERSION where ZUUID='" & curID & "'\""
    set ZFILEUUID to do shell script theScript
    # ---------- Get the master's path
    set theScript to p_sql & (quoted form of libDBPOSIX) & " \"select ZIMAGEPATH from ZRKFILE where ZUUID='" & ZFILEUUID & "'\""
    set ZIMAGEPATH to do shell script theScript
    # ---------- Get the master's disk name
    set theScript to p_sql & (quoted form of libDBPOSIX) & " \"select ZFILEVOLUMEUUID from ZRKFILE where ZUUID='" & ZFILEUUID & "'\""
    set ZFILEVOLUMEUUID to do shell script theScript
    set theScript to p_sql & (quoted form of libDBPOSIX) & " \"select ZNAME from ZRKVOLUME where ZUUID='" & ZFILEVOLUMEUUID & "'\""
    set diskName to do shell script theScript
    set imgPath to (diskName & "/" & ZIMAGEPATH)
    --end brett gross part
    --strips extension, seems to work for files and paths with more than one period
    set oldlim to AppleScript's text item delimiters
    set AppleScript's text item delimiters to "."
    try --remove last extension only
    set contador to text item -1 of imgPath
    set noExtension to Unicode text 1 thru -((count of contador) + 2) of imgPath
    on error --handle files with no extensions
    set noExtension to imgPath
    end try
    set AppleScript's text item delimiters to oldlim
    --create the file and path name with the .xmp extension for writing
    set xmpPath to "/Volumes/" & noExtension & ".xmp" as Unicode text
    --convert posix path to alias for easier write and read handling
    set xmpPath to POSIX file xmpPath as file specification
    -- header for xmp file
    set xmpheader to ("<?xpacket begin='' id=''?>
    <x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='XMP toolkit 2.9-9, framework 1.6'>
    <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:iX='http://ns.adobe.com/iX/1.0/'>") & return
    -- footer for xmp file
    set xmpfooter to ("</rdf:RDF>
    </x:xmpmeta>
    <?xpacket end='w'?>") & return
    --xmp content, part 1
    --check for existence of iptc tags, create content or empty string depending on existance of tags
    if (exists IPTC tag "Contact") or (exists IPTC tag "Country/PrimaryLocationCode") then
    set xmpcontentpartone to ("<rdf:Description rdf:about='' xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>") & return
    try
    set CountryCode to value of IPTC tag "Country/PrimaryLocationCode"
    set xmpcontentpartone to xmpcontentpartone & tab & "<Iptc4xmpCore:CountryCode>" & CountryCode & "</Iptc4xmpCore:CountryCode>" & return
    end try
    try
    set CreatorContactInfo to value of IPTC tag "Contact"
    set xmpcontentpartone to xmpcontentpartone & tab & "<Iptc4xmpCore:CreatorContactInfo>" & CreatorContactInfo & "</Iptc4xmpCore:CreatorContactInfo>" & return
    end try
    set xmpcontentpartone to xmpcontentpartone & ("</rdf:Description>") & return
    else
    set xmpcontentpartone to ""
    end if
    --xmp content, part 2
    --check for existence of iptc tags, create content or empty string depending on existance of tags
    if (exists IPTC tag "Category") or (exists IPTC tag "City") or (exists IPTC tag "Country/PrimaryLocationName") or (exists IPTC tag "Credit") or (exists IPTC tag "DateCreated") or (exists IPTC tag "Headline") or (exists IPTC tag "Province/State") or (exists IPTC tag "Source") or (exists IPTC tag "SpecialInstructions") or (exists IPTC tag "SupplementalCategory") or (exists IPTC tag "Writer/Editor") then
    set xmpcontentparttwo to ("<rdf:Description rdf:about='' xmlns:photoshop='http://ns.adobe.com/photoshop/1.0/'>") & return
    try
    set Category to value of IPTC tag "Category"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:Category>" & Category & "</photoshop:Category>" & return
    end try
    try
    set City to value of IPTC tag "City"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:City>" & City & "</photoshop:City>" & return
    end try
    try
    set Country to value of IPTC tag "Country/PrimaryLocationName"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:Country>" & Country & "</photoshop:Country>" & return
    end try
    try
    set Credit to value of IPTC tag "Credit"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:Credit>" & Credit & "</photoshop:Credit>" & return
    end try
    try
    set DateCreated to value of IPTC tag "DateCreated"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:DateCreated>" & DateCreated & "</photoshop:DateCreated>" & return
    end try
    try
    set Headline to value of IPTC tag "Headline"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:Headline>" & Headline & "</photoshop:Headline>" & return
    end try
    try
    set State to value of IPTC tag "Province/State"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:State>" & State & "</photoshop:State>" & return
    end try
    try
    set Source to value of IPTC tag "Source"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:Source>" & Source & "</photoshop:Source>" & return
    end try
    try
    set Instructions to value of IPTC tag "SpecialInstructions"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:Instructions>" & Instructions & "</photoshop:Instructions>" & return
    end try
    try
    set SupplementalCategory to value of IPTC tag "SupplementalCategory"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:SupplementalCategory>" & SupplementalCategory & "</photoshop:SupplementalCategory>" & return
    end try
    try
    set CaptionWriter to value of IPTC tag "Writer/Editor"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:CaptionWriter>" & CaptionWriter & "</photoshop:CaptionWriter>" & return
    end try
    set xmpcontentparttwo to xmpcontentparttwo & ("</rdf:Description>") & return
    else
    set xmpcontentparttwo to ""
    end if
    --xmp content, part 3
    --check for existence of iptc tags, create content or empty string depending on existance of tags
    if (exists IPTC tag "Byline") or (exists IPTC tag "Caption/Abstract") or (exists IPTC tag "CopyrightNotice") or (exists IPTC tag "Keywords") or (exists IPTC tag "ObjectName") then
    set xmpcontentpartthree to ("<rdf:Description rdf:about='' xmlns:dc='http://purl.org/dc/elements/1.1/'>") & return
    try
    set creator to value of IPTC tag "Byline"
    set xmpcontentpartthree to xmpcontentpartthree & tab & "<dc:creator><rdf:Seq><rdf:li>" & creator & "</rdf:li></rdf:Seq></dc:creator>" & return
    end try
    try
    set description to value of IPTC tag "Caption/Abstract"
    set xmpcontentpartthree to xmpcontentpartthree & tab & "<dc:description><rdf:Alt><rdf:li xml:lang='x-default'>" & description & "</rdf:li></rdf:Alt></dc:description>" & return
    end try
    try
    set rights to value of IPTC tag "CopyrightNotice"
    set xmpcontentpartthree to xmpcontentpartthree & tab & "<dc:rights><rdf:Alt><rdf:li xml:lang='x-default'>" & rights & "</rdf:li></rdf:Alt></dc:rights>" & return
    end try
    --keywords, slightly different, as they need to be written as a list and not as a string
    --i don't think it's a problem if we create an empty list if there are no keywords present.
    set xmpcontentpartthree to xmpcontentpartthree & tab & "<dc:subject><rdf:Bag>" & return
    --make list item for every keyword
    try
    repeat with n from 1 to count of keywords
    set cursubject to name of (keyword n)
    set xmpcontentpartthree to xmpcontentpartthree & tab & tab & "<rdf:li>" & cursubject & "</rdf:li>" & return
    end repeat
    end try
    set xmpcontentpartthree to xmpcontentpartthree & tab & "</rdf:Bag></dc:subject>" & return
    try
    set title to value of IPTC tag "ObjectName"
    set xmpcontentpartthree to xmpcontentpartthree & tab & "<dc:title><rdf:Alt><rdf:li xml:lang='x-default'>" & title & "</rdf:li></rdf:Alt></dc:title>" & return
    end try
    set xmpcontentpartthree to xmpcontentpartthree & ("</rdf:Description>") & return
    else
    set xmpcontentpartthree to ""
    end if
    --part four. aperture doesn't seem to export anything there
    set xmpcontentpartfour to "<rdf:Description rdf:about='' xmlns:photomechanic='http://ns.camerabits.com/photomechanic/1.0/'>
    </rdf:Description>" & return
    --part five. rating
    set xmpcontentpartfive to "<rdf:Description rdf:about='' xmlns:xap='http://ns.adobe.com/xap/1.0/'>" & return
    try
    set Rating to main rating
    set xmpcontentpartfive to xmpcontentpartfive & tab & "<xap:Rating>" & Rating & "</xap:Rating>" & return
    end try
    set xmpcontentpartfive to xmpcontentpartfive & "</rdf:Description>" & return
    --join everything
    set xmptext to xmpheader & xmpcontentpartone & xmpcontentparttwo & xmpcontentpartthree & xmpcontentpartfour & xmpcontentpartfive & xmpfooter
    --write file
    my writexmpFile(xmptext, xmpPath)
    end if
    end tell
    end repeat
    display dialog "Processed " & mastercount & " referenced and online image(s)." buttons {"OK"} default button 1
    end tell
    end run
    -- write xmp sidecar file routine
    on writexmpFile(theContents, xmpFileName)
    --tell application "Finder"
    try
    open for access xmpFileName with write permission
    set eof of xmpFileName to 0
    write (theContents) to xmpFileName starting at eof
    close access xmpFileName
    on error
    try
    display dialog xmpFileName
    close access xmpFileName
    end try
    end try
    --end tell
    end writexmpFile
    --this part copied from Brett Gross-------------------------------------------------------------------------- --------------------------------
    on getLibPath()
    tell application "System Events" to set p_libPath to value of property list item "LibraryPath" of property list file ((path to preferences as Unicode text) & "com.apple.aperture.plist")
    if ((offset of "~" in p_libPath) is not 0) then
    -- set p_posix to POSIX file p_libPath
    set p_script to "/bin/echo $HOME"
    set p_homePath to (do shell script p_script)
    set p_offset to offset of "~" in p_libPath
    set p_path to text (p_offset + 1) thru -1 of p_libPath
    set g_libPath to p_homePath & p_path
    else
    set g_libPath to p_libPath
    end if
    end getLibPath
    --end brett gross part

    imigra wrote:
    I've written a script to write xmp sidecar files for referenced and online images (the 2 conditions in the script) of the selected images. I looked for a while at system events and other stuff to be able to write the xmp file, but i'm not a programmer, so in the end i chose the long and dirty way to do it.
    This script will export all iptc expanded fields as aperture does (creating basically the same file). It can be easily adjusted to include other tags, even custom ones.
    Excellent stuff!
    I don't know how to get at the adjustments for images, otherwise those could be included as well.
    They are stored as binary data in the Version XML files at the bottom level of the Library package. You can also have a look around in the ZRKIMAGEADJUSTMENT table, but again the actual settings for each adjustment are in binary form.
    If anyone has the energy to clean this up and make it faster, feel free to do so.
    As far as I can remember, Aperture uses the 'proper' IPTC tag names when accessing them via AppleScript, so you may be able to do a loop through all the IPTC tags for each image, rather than picking out each specific one. But that would need checking. The EXIFTools site is a good place to find out about the different ways that IPTC data can be described.
    Next, I'm going to try to write a script to do the opposite, import xmp sidecars for imported online and referenced files.
    Don't rush unless you feel like it - I've already started planning out a free (as in beer and speech) XMP importer with a GUI so that you can choose how to map the XMP CORE tags that don't exist in Aperture. You've given me an extra idea, though - if we can decide on a set of custom tags, my importer could map the XMP CORE tags to them and your exporter could export those tags.
    Thanks for the work!
    Ian
    P.S. I'll check through your script tomorrow, some of the database tables changed between 1.5.6 and 2.0, so you might need to add in a version check to be really thorough.

  • Extracting an .xmp sidecar from an ACR-edited RAW smart object layer...

    Hello all.  Given the following situation:
    Several thousand TIFF files, each containing two RAW files embedded into separate Smart Object layers.  The RAW files were named with sequential numbers prior to being composited into the TIFF files via a script, and the TIFF filenames correspond to those of the embedded RAW files.  The RAWs have subsequently been edited in ACR from within the TIFF files.
    I've done a little digging, but I can't seem to turn up answers to several related questions:
    A) Should I wish to re-extract the RAW files from the smart object layers with the edits that have been applied, is there a method of PerLayerMetdata that can be used to extract a complete .xmp sidecar that will be recognized by ACR and associated with the exported RAW?
    B) Should I wish to change the sequential-naming of the parent TIFF files, is there any method to correspondingly change the filenames of the embedded RAWs directly within the smart object layer?  In other words, using PerLayerMetdata, can the filenames of the RAWs be changed without exporting the RAWs using a different filename and then replacing the contents of the smart object layer?
    C) I would ultimately like to be able to save the embedded RAWs as DNGs with their ACR edits applied, if necessaray.  Given a way to accomplish A), above, it would be a fairly simple to export the RAWs and associated .xmp files and then run the DNG converter on the lot.  However, does anyone know of a way to save a DNG directly from the smart object layer?
    Any ideas or pointers to existing documentation are much appreciated.

    Thank you kindly, Michael.  I see now that the example I was viewing had done exactly what you describe, writing ACR settings into the SO layer's metadata at the time of embedding.  I was only looking at the portion which later accessed those settings using PerLayerMetadata, and I had mistakenly assumed that CS5 was automatically embedding xmp data in this manner, now, when opening or placing a RAW file as a SO.
    I don't see a direct way to get at the ACR settings of a camera raw file embedded in a smart object.
    This is sort of what I was afraid of.  They're in there, somewhere, but I'm having no luck figuring out how to access them.
    If the ACR settings for a RAW smart object are, indeed, not exposed to automation in some manner, I think I must change my workflow such that either: A) No edits are performed in ACR after object embedding; or B) the RAWs are converted to DNGs prior to smart-object embedding so that the ACR settings can be exposed in the exported file.

  • How do I force lightroom to (re)load an XMP sidecar file?

    Good morning from Boston!
    I am new to Lightroom and just finished importing my Aperture library into Lightroom 5 on a Mac. For that, I followed the instructions on Adobe's landing page and Lightroom solutions. For those not familiar with the instructions, you essentially export all your originals with an XMP sidecar file and then export all the adjusted/edited files as 16-bit TIFFs. Then you add them all back into Lightroom and get everything back into Catalogs, Labels, Ratings, and such by using keywords that were added while in Aperture. It took forever, but worked pretty well overall. I had about <1% fewer images in LR5 than in Aperture, which were likely suspected duplicates. So far, so good.
    Here's is my problem. My keywords didn't always transfer over (the Keywording panel is empty). I did search forums and plug-ins, but seem to only find issues related to EXIF and GPS data. I also used "Metadata:Read Metadata from File" and "Metadata:Update DNG Preview & Metadata," which didn't do anything. I am suspecting that "Read from File" means "read from the image file itself but not from the sidecar file." Take file IMG_5888 as an example. This particular one was taken as RAW (.CR2) + JPEG on a Canon Rebel XS, but I am having the same issue with RAW only on my Canon EOS 6D. Same goes for JPG + XMP. Puzzling thing is that other files loaded just fine.
    In the directory/folder where the file is, it looks like this:
    IMG_5887.CR2
    IMG_5887.JPG
    IMG_5887.XMP
    IMG_5887.dng
    IMG_5888-2.JPG
    IMG_5888.CR2
    IMG_5888.JPG
    IMG_5888.XMP
    IMG_5888.dng
    IMG_5889-2.JPG
    IMG_5889.CR2
    IMG_5889.JPG
    IMG_5889.XMP
    IMG_5889.dng
    The .dng were generated by Llightroom. Now, the sidecar files typically have something like so in them (I cut out some keywords for clarity—you get the idea):
    <rdf:Description rdf:about='' xmlns:photoshop='http://ns.adobe.com/photoshop/1.0/'>
    </rdf:Description>
    <rdf:Description rdf:about='' xmlns:dc='http://purl.org/dc/elements/1.1/'>
      <dc:subject><rdf:Bag>
      <rdf:li>Black Head Trail</rdf:li>
      <rdf:li>Cliffs</rdf:li>
      <rdf:li>Maine</rdf:li>
      <rdf:li>Monhegan</rdf:li>
      <rdf:li>RAW</rdf:li>
      <rdf:li>Sunrises</rdf:li>
      <rdf:li>United States</rdf:li>
      <rdf:li>Waves</rdf:li>
      </rdf:Bag></dc:subject>
    </rdf:Description>
    So, the keywords were exported from Aperture, but for some reason, Lightroom isn't always loading them from the XMP file.
    On a related note, the keyword hierarchy that was exported as text file from Aperture and imported into LR5 worked well. Everything appears to be there and in its place.
    Any ideas for a Lightroom rookie as to how I can get LR5 to read those XMPs? Over 20,000 didn't tag, so I would rather not do this by hand!
    Many thanks in advance,
    Paul

    John, what a pleasure. Well, here is the update. First, copying over 300GB of pictures to a drive and then backing up said drive takes a bloody long time. But here is what happened, for others who might run into the same issue.
    I first tried a small set of files to narrow down whether the issue was the Aperture export or the Lightroom import.
    Conclusion: the "issue" is mostly on the Lightroom side.
    What I found: Although Aperture will export an XMP sidecar for a JPEG, Lightroom will not read it, ignoring all keywords. I exported a set of JPEGs only and then opened the XMPs with an editor (well, the UNIX cat command, to be exact). The information was there, keywords and all. However, LR appeared to ignore XMP for JPEG. That said, if you have a RAW+JPEG in Aperture, the RAW XMP sidecar will overwrite the JPEG one, effectively leaving you with only the keywords for the RAW version. That shouldn't be an issue for most, but just in case you have different keywords for your RAW and JPEG images, be aware of this.
    What I did:
    Back up all the images and catalogs/libraries from Aperture and LR.
    Make sure #1 worked out.
    Make sure #1 worked out (not a typo; you really need a backup, as you will find out below).
    Delete the old JPEG files that were uploaded into LR. I had them in a From Aperture folder, as instructed by John's article and Adobe's landing page (referenced in John's article), so I deleted all JPEGs in that folder. My Aperture database was not affected and in fact resides on a different drive.
    Run find . -iname "*.JPEG" -delete   [if you do not know how 'find' works, ask someone, as this can potentially delete every single file accessible to your computer!]
    Run find . -iname "*.JPG" -delete    [ditto! Don't tell me I didn't warn you!]This is why you need to backup everything. I was deleting copies/exports of the originals in Aperture (again, read John's article for the difference) and still had the originals in Aperture, on a different drive.
    [I didn't worry about the unmatched/orphaned XMP files for the JPEGs only; they are tiny and don't hurt.]
    In LR, select 'Library:Find All Missing Photos.' If asked, remove them from the Catalog only.
    Create a Smart Album in Aperture and include only 'Filetype is JPG.'
    Select all images in that album.
    Export those original images per Adobe's landing instructions, but for this set of images, select 'Include IPTC' instead of creating a sidecar file.
    When Aperture is done, open LR and Add the whole 'From Aperture' folder back to LR (make sure 'Ignore suspected duplicates' is selected.
    John, as you rightfully pointed out, this is tricky. If my experience is any indicator, I would suggest migrating in 3 steps:
    Export all RAW originals with IPTC in XMP sidecar files.
    Export all non-RAW originals (which I would guess are mostly JPEGs) with IPTC included. (not a sidecar)
    Export all versions as 16-bit TIFF.
    If #2 is added, then the process is actually most straightforward. Steps 1–5 in the first block above were to clean up the mess that I had created and should not happen otherwise (famous last word...)
    If the above is unclear, please let me know and I will expand on it. If I had the issue, I suspect others will as well.
    Thank you for your help and suggestions. I am officially migrated to LR and up and running!
    Cheers from Boston,
    Paul

  • Re: updating XMP sidecar-file for NEF files

    [Reply to a message mistakenly posted in the SDK forum:
    http://forums.adobe.com/thread/1158444?tstart=0]
    Adobe has stated that LR 3.4 and later follow the standard "Guidelines For Handling Image Metadata" from the Metadata Working Group, which incorporates the EXIF and IPTC standards.  Adobe continues to make incremental improvements to LR's metadata handling, so I'll just focus on the behavior of the current release, 4.3.  Following the detailed steps you posted:
    LR 4.3 does not add Photoshop:Urgency to the .xmp sidecar.   As you've observed, Photoshop:Urgency is a deprecated field not part of the IPTC Core, so that makes sense.
    LR 4.3 does copy the XMP field MicrosoftPhoto:RatingPercent from the .nef to the .xmp, but it doesn't update that field when you change the Rating in LR.   Both of these behaviors make sense.  RatingPercent is not part of the standards supported by LR, so of course it won't update that field.  But it is part of the XMP metadata in the .nef, and tools should in general preserve all of the XMP metadata, even if they don't use it or know how to interpret it (XMP = "Extensible Metadata Platform").

    [Reply to a message mistakenly posted in the SDK forum:
    http://forums.adobe.com/thread/1158444?tstart=0]
    Adobe has stated that LR 3.4 and later follow the standard "Guidelines For Handling Image Metadata" from the Metadata Working Group, which incorporates the EXIF and IPTC standards.  Adobe continues to make incremental improvements to LR's metadata handling, so I'll just focus on the behavior of the current release, 4.3.  Following the detailed steps you posted:
    LR 4.3 does not add Photoshop:Urgency to the .xmp sidecar.   As you've observed, Photoshop:Urgency is a deprecated field not part of the IPTC Core, so that makes sense.
    LR 4.3 does copy the XMP field MicrosoftPhoto:RatingPercent from the .nef to the .xmp, but it doesn't update that field when you change the Rating in LR.   Both of these behaviors make sense.  RatingPercent is not part of the standards supported by LR, so of course it won't update that field.  But it is part of the XMP metadata in the .nef, and tools should in general preserve all of the XMP metadata, even if they don't use it or know how to interpret it (XMP = "Extensible Metadata Platform").

  • XMP sidecar files not recognised

    I am new to Lightroom and want to migrate an Expression Media catalog to a LR catalog.
    The import worked OK for the images (raw/Nef, Tiff, jpeg) , but I have a problem with the IPCT medata ( so far I use only : title, rating, country, copyright).
    I don't like the idea of writing this medata into the image files , using the Sync command in Expression Media.
    So I created xmp sidecar files for all images nef, tiff and jpeg ('extract metadata / annotations only'  command in XM).
    Image files and sidecar files have the same name and are stored in the same folder.
    LR imported the metadata for raw images only, not for tiff or jpeg.
    I guess xmp 'space' is supposed to be inside tiff and jpeg image files, and outside raw files (sidecar files), but is there a way to have LR import consider sidecar files for non raw files ?  (strangely, 'sidecar files : xmp' is mentioned in the metadata panel for tiff files, not for jpegs)
    Thanks for your help,
    Lenanard

    but is there a way to have LR import consider sidecar files for non raw files ?
    No. Xmp's only for proprietary raw file. For others Lightroom only rads embedded.
    (strangely, 'sidecar files : xmp' is mentioned in the metadata panel for tiff files, not for jpegs)
    Lightroom just looks at whatever files are there with a common base name. You can even have a TXT file as a sidecar.

  • Importing XMP sidecar with PSD files

    I've got a boatload of PSD files in Aperture with keywords and other metadata. I want to import these into LR5.
    Aperture will not (AFAIK) write the metadata I have in Aperture to the files themselves since they are PSDs. But it does write to XMP files, so I exported a test batch, PSD + sidecar of same name to a folder. I go to import that folder into LR5 and it works, except no metadata.
    I checked the metadata in the sidecars with a text editor; it's there.
    I tried the Metadata>Read Metadata from File menu; nothing.
    What's up?

    Thanks. One problem is that Aperture doesn't seem to put things in the XMP that I'm interested in, or in places I wanted in sidecars. I didn't get too far into it, but it seemed to write a more complete set of data into the tiffs than into the sidecar for the same file. I didn't really care if it was in XMP or exif or IPTC or wherever as long as it was useful in LR. As it turned out, exporting to tiff with the metadata from Aperture was the fastest way to go for thousands of files.
    BTW, anyone have a nice chart with where various bits of metadata are stored by common applications? Although each has it's own standard there doesn't seem to be enough agreement about where a "keyword" or "tag" winds up in exif, IPTC, XMP, xattr, etc. Annoying. Supposedly Mavericks in the MacOS is gonna have some support for tagging (gee, welcome to the 21st century) in lieu of labels; wonder if they'll make any use of any of the formats we use.
    BTW, Graphic Converter 8 was very helpful in massinging metadata and reorganizing in the move from Aperture to LR. After all these years it still proves to be super useful.

  • Importing XMP sidecar files

    I used Lightroom to catalogue my pictures as Aperture would not run on my G4. I have now upgraded my computer and have purchased Aperture. I exported my pictures out of Lightroom with XMP sidecar files. On importing my pictures into Aperture I do not have the ratings and keywords assigned in Lightroom. Is there any way I can import the side car files or do I have to rate my pictures again and add the keywords manually?

    The XMP import capability is limited to metadata/IPTC type info - NOT ACR adjustments and such - those values are specific and make no sense to Aperture. This is true in reverse as well - ACR/Bridge/LR/NX2, etc, etc may pickup IPTC type metadata from XMP or embedded values but NO software will translate adjustment values from another piece of software that are stored ad metadata.
    RB

  • XMP Sidecar problems with remove and copy

    Perhaps it should be documented that File.remove() does not delete the corresponding .xmp file.  I think it can be argued that removing the xmp is more correct than leaving the sidecar there.<br /><br />This leads to problems when subsequently renaming some other file (with .xmp) to the name of the deleted file.  The rename gets an error, claiming the file exists but not mentioning that it is the invisible .xmp that actually exists.<br /><br />Then, oddly, ESCing from the error dialog actually does rename the file, but renames the corresponding .xmp as <name>(1).xmp -- attaching the wrong sidecar to the renamed image.

    Jack,
    This is pretty much as designed. The File class knows nothing about sidecars. Try using the Thumbnail class instead. A Thumbnail object in Bridge scripting should have all the built-in sidecar file smarts that Bridge uses when you manipulate thumbnails in the Bridge user interface.
    -David Franzen
    Adobe Bridge Quality Engineer

  • Scripting oracle export and import dumps through PLSQL stored procedures

    Hello,
    I would like to know if it is possible to script oracle export and import dump commands in a PL/SQL package rather than at command prompt. Also, how can i copy the export dump files across the network to a specific location.
    I would really appreciate if someone can provide me with examples????
    OR
    If there is off the shelf solution for what i am trying to achieve?
    Many Thanks.

    Hello,
    there are many ways to do this:
    - Java with PL/SQL wrapper,
    - call C code as external procedure from PL/SQL,
    - DBMS_SCHEDULER has some features related to this as well,
    - or write your own logic: for example creating a new file with UTL_FILE could be the trigger of the export.
    Franky
    Edited by: Franky on Aug 10, 2009 4:25 AM - extended

  • External xmp file for JPEG

    Hi,
    Is there any possibility to save develop settings for JPEG file into external XMP file - not inside JPEG?
    It is confusing for all backup software. Backup system have to transfer all modified JPEG files - not lightweight xmp files. Moreover, modification date of original JPEG file changes. I would like to have all my original JPEG files untouched as RAW files.
    Thanks for suggestions
    Sebastian

    ksebman wrote:
    My backup software transfers files through the Internet. So if I make small changes to hundreds of files, I have to transfer all JPEGs which are relatively huge. It takes a long time. External xmp file would be better because of its textual nature and size. Moreover I would like to have original files, not modified by any software (even if image data is untouched). I do like the way how RAW files are handled - no modifications at all.
    I know, there are people who like having metadata in JPEG files because they use other applications. Searching through the Internet I found that there is a lot of people who decide not to use LR from that reason (modified original JPEG file). They set read-only attribute for all JPEGs to prevent this behavior.
    It's really inconvenient - possibility to save external XMP file as in RAW files would be very helpful.
    Best Regards
    Sebastian
    You do not need to back up all those JPEGs after each change. Back them up once at the start, and then back up the lrcat file (maybe zipped) routinely. This means both the original image data and all your editing work are backed up, and you could reconstruct your picture collection perfectly from your backup. The sidecar-based backup scheme would mean that all your work wouldn't be backed up (or you'd be forced to avoid a range of Lightroom features).
    It's a wrong-headed reason to avoid LR. XMP is not written into proprietary raw files because Adobe consider it too risky. With JPEGs, it isn't - and if you are worried, just backup a virgin JPEG immediately after importing them.
    John

  • I am having trouble keeping the quality of my video when exporting to my external drive.  I change the kind to "original" but when I view the video from the external drive once exported, the sound and picture are distorted.

    I am having trouble keeping the quality of my video when exporting to my external hard drive.  I have tried to export from iphoto with changing kind to "original" but when I open the video from the external drive the quality is effected.  I have also tried copying the video to my desktop and then dragging and dropping onto the drive...same problem. Any suggestions?  I would like to save everything to my external drive so that I can delete all of iphoto library and then reimport to correct a few things.

    The file sizes are identical.  In the finder I did a search for all .mov files.  Then when they came up, I went through them and named each one so that they would be easier to find.  I am a new mac user and am used to windows.  I realized later that I should not have done this....with a mac files should be named within iphoto app...not finder....When I went to open the videos in iphoto, it wouldn't allow me.  I had to go into finder, copy to desktop and reimport into iphoto.  Then the videos worked again.  However, I had the problem with the poor video quality when copied to external drive before that.  Actually the first problem I had was when I copied to ext drive...videos were copying as an image...so I learned that you have to change "kind" to original before exporting....then that problem was solved...now they are videos, not images but not of a great quality.  Skips, sound and images are not in sync...etc...

  • Script to Export Pervious Day Events Logs to CSV

    HI,
    I am trying to export all the previous day's application event logs to a CSV file. I found the following script on net. But for this script to work I need to enter in the Event ID's I wont to export. Does anyone have any idea how I can change thsi script
    to export all event ID's or have another script that can?
    'Description : This script queries the event log for...whatever you want it to! Just set the event 'log name and event ID's!
    'Initialization  Section
    Option Explicit
    Const ForReading   = 1
    Const ForWriting   = 2
    Const ForAppending = 8
    Dim objDictionary, objFSO, wshShell, wshNetwork
    Dim scriptBaseName, scriptPath, scriptLogPath
    Dim ipAddress, macAddress, item, messageType, message
    On Error Resume Next
       Set objDictionary = NewDictionary
       Set objFSO        = CreateObject("Scripting.FileSystemObject")
       Set wshShell      = CreateObject("Wscript.Shell")
       Set wshNetwork    = CreateObject("Wscript.Network")
       scriptBaseName    = objFSO.GetBaseName(Wscript.ScriptFullName)
       scriptPath        = objFSO.GetFile(Wscript.ScriptFullName).ParentFolder.Path
       scriptLogPath     = scriptPath & "\" & IsoDateString(Now)
       If Err.Number <> 0 Then
          Wscript.Quit
       End If
    On Error Goto 0
    'Main Processing Section
    On Error Resume Next
       PromptScriptStart
       ProcessScript
       If Err.Number <> 0 Then
          MsgBox BuildError("Processing Script"), vbCritical, scriptBaseName
          Wscript.Quit
       End If
       PromptScriptEnd
    On Error Goto 0
    'Functions Processing Section
    'Name       : ProcessScript -> Primary Function that controls all other script processing.
    'Parameters : None          ->
    'Return     : None          ->
    Function ProcessScript
       Dim hostName, logName, startDateTime, endDateTime
       Dim events, eventNumbers, i
       hostName      = wshNetwork.ComputerName
       logName       = "application"
       eventNumbers  = Array("1001","1")
       startDateTime = DateAdd("n", -21600, Now)
       'Query the event log for the eventID's within the specified event log name and date range.
       If Not QueryEventLog(events, hostName, logName, eventNumbers, startDateTime) Then
          Exit Function
       End If
       'Log the scripts results to the scripts
       For i = 0 To UBound(events)
          LogMessage events(i)
       Next
    End Function
    'Name       : QueryEventLog -> Primary Function that controls all other script processing.
    'Parameters : results       -> Input/Output : Variable assigned to an array of results from querying the event log.
    '           : hostName      -> String containing the hostName of the system to query the event log on.
    '           : logName       -> String containing the name of the Event Log to query on the system.
    '           : eventNumbers  -> Array containing the EventID's (eventCode) to search for within the event log.
    '           : startDateTime -> Date\Time containing the date to finish searching at.
    '           : minutes       -> Integer containing the number of minutes to subtract from the startDate to begin the search.
    'Return     : QueryEventLog -> Returns True if the event log was successfully queried otherwise returns False.
    Function QueryEventLog(results, hostName, logName, eventNumbers, startDateTime)
       Dim wmiDateTime, wmi, query, eventItems, eventItem
       Dim timeWritten, eventDate, eventTime, description
       Dim eventsDict, eventInfo, errorCount, i
       QueryEventLog = False
       errorCount    = 0
       If Not IsArray(eventNumbers) Then
          eventNumbers = Array(eventNumbers)
       End If
       'Construct part of the WMI Query to account for searching multiple eventID's
       query = "Select * from Win32_NTLogEvent Where Logfile = " & SQ(logName) & " And (EventCode = "
       For i = 0 To UBound(eventNumbers)
          query = query & SQ(eventNumbers(i)) & " Or EventCode = "
       Next
       On Error Resume Next
          Set eventsDict = NewDictionary
          If Err.Number <> 0 Then
             LogError "Creating Dictionary Object"
             Exit Function
          End If
          Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate,(Security)}!\\" & hostName & "\root\cimv2")
          If Err.Number <> 0 Then
             LogError "Creating WMI Object to connect to " & DQ(hostName)
             Exit Function
          End If
          'Create the "SWbemDateTime" Object for converting WMI Date formats. Supported in Windows Server 2003 & Windows XP.
          Set wmiDateTime = CreateObject("WbemScripting.SWbemDateTime")
          If Err.Number <> 0 Then
             LogError "Creating " & DQ("WbemScripting.SWbemDateTime") & " object"
             Exit Function
          End If
          'Build the WQL query and execute it.
          wmiDateTime.SetVarDate startDateTime, True
          query          = Left(query, InStrRev(query, "'")) & ") And (TimeWritten >= " & SQ(wmiDateTime.Value) & ")"
          Set eventItems = wmi.ExecQuery(query)
          If Err.Number <> 0 Then
             LogError "Executing WMI Query " & DQ(query)
             Exit Function
          End If
          'Convert the property values of Each event found to a comma seperated string and add it to the dictionary.
          For Each eventItem In eventItems
             Do
                timeWritten = ""
                eventDate   = ""
                eventTime   = ""
                eventInfo   = ""
                timeWritten = ConvertWMIDateTime(eventItem.TimeWritten)
                eventDate   = FormatDateTime(timeWritten, vbShortDate)
                eventTime   = FormatDateTime(timeWritten, vbLongTime)
                eventInfo   = eventDate                          &
                eventInfo   = eventInfo & eventTime              & ","
                eventInfo   = eventInfo & eventItem.SourceName   & ","
                eventInfo   = eventInfo & eventItem.Type         & ","
                eventInfo   = eventInfo & eventItem.Category     & ","
                eventInfo   = eventInfo & eventItem.EventCode    & ","
                eventInfo   = eventInfo & eventItem.User         & ","
                eventInfo   = eventInfo & eventItem.ComputerName & ","
                description = eventItem.Message
                'Ensure the event description is not blank.
                If IsNull(description) Then
                   description = "The event description cannot be found."
                End If
                description = Replace(description, vbCrLf, " ")
                eventInfo   = eventInfo & description
                'Check if any errors occurred enumerating the event Information
                If Err.Number <> 0 Then
                   LogError "Enumerating Event Properties from the " & DQ(logName) & " event log on " & DQ(hostName)
                   errorCount = errorCount + 1
                   Err.Clear
                   Exit Do
                End If
                'Remove all Tabs and spaces.
                eventInfo = Trim(Replace(eventInfo, vbTab, " "))
                Do While InStr(1, eventInfo, "  ", vbTextCompare) <> 0
                   eventInfo = Replace(eventInfo, "  ", " ")
                Loop
                'Add the Event Information to the Dictionary object if it doesn't exist.
                If Not eventsDict.Exists(eventInfo) Then
                   eventsDict(eventsDict.Count) = eventInfo
                End If
             Loop Until True
          Next
       On Error Goto 0
       If errorCount <> 0 Then
          Exit Function
       End If
       results       = eventsDict.Items
       QueryEventLog = True
    End Function
    'Name       : ConvertWMIDateTime -> Converts a WMI Date Time String into a String that can be formatted as a valid Date Time.
    'Parameters : wmiDateTimeString  -> String containing a WMI Date Time String.
    'Return     : ConvertWMIDateTime -> Returns a valid Date Time String otherwise returns a Blank String.
    Function ConvertWMIDateTime(wmiDateTimeString)
       Dim integerValues, i
       'Ensure the wmiDateTimeString contains a "+" or "-" character. If it doesn't it is not a valid WMI date time so exit.
       If InStr(1, wmiDateTimeString, "+", vbTextCompare) = 0 And _
          InStr(1, wmiDateTimeString, "-", vbTextCompare) = 0 Then
          ConvertWMIDateTime = ""
          Exit Function
       End If
       'Replace any "." or "+" or "-" characters in the wmiDateTimeString and check each character is a valid integer.
       integerValues = Replace(Replace(Replace(wmiDateTimeString, ".", ""), "+", ""), "-", "")
       For i = 1 To Len(integerValues)
          If Not IsNumeric(Mid(integerValues, i, 1)) Then
             ConvertWMIDateTime = ""
             Exit Function
          End If
       Next
       'Convert the WMI Date Time string to a String that can be formatted as a valid Date Time value.
       ConvertWMIDateTime = CDate(Mid(wmiDateTimeString, 5, 2)  & "/" & _
                                  Mid(wmiDateTimeString, 7, 2)  & "/" & Left(wmiDateTimeString,
    4) & " " & _
                                  Mid(wmiDateTimeString, 9, 2)  & ":" & _
                                  Mid(wmiDateTimeString, 11, 2) & ":" & _
                                  Mid(wmiDateTimeString, 13, 2))
    End Function
    'Name       : NewDictionary -> Creates a new dictionary object.
    'Parameters : None          ->
    'Return     : NewDictionary -> Returns a dictionary object.
    Function NewDictionary
       Dim dict
       Set dict          = CreateObject("scripting.Dictionary")
       dict.CompareMode  = vbTextCompare
       Set NewDictionary = dict
    End Function
    'Name       : SQ          -> Places single quotes around a string
    'Parameters : stringValue -> String containing the value to place single quotes around
    'Return     : SQ          -> Returns a single quoted string
    Function SQ(ByVal stringValue)
       If VarType(stringValue) = vbString Then
          SQ = "'" & stringValue & "'"
       End If
    End Function
    'Name       : DQ          -> Place double quotes around a string and replace double quotes
    '           :             -> within the string with pairs of double quotes.
    'Parameters : stringValue -> String value to be double quoted
    'Return     : DQ          -> Double quoted string.
    Function DQ (ByVal stringValue)
       If stringValue <> "" Then
          DQ = """" & Replace (stringValue, """", """""") & """"
       Else
          DQ = """"""
       End If
    End Function
    'Name       : IsoDateTimeString -> Generate an ISO date and time string from a date/time value.
    'Parameters : dateValue         -> Input date/time value.
    'Return     : IsoDateTimeString -> Date and time parts of the input value in "yyyy-mm-dd hh:mm:ss" format.
    Function IsoDateTimeString(dateValue)
       IsoDateTimeString = IsoDateString (dateValue) & " " & IsoTimeString (dateValue)
    End Function
    'Name       : IsoDateString -> Generate an ISO date string from a date/time value.
    'Parameters : dateValue     -> Input date/time value.
    'Return     : IsoDateString -> Date part of the input value in "yyyy-mm-dd" format.
    Function IsoDateString(dateValue)
       If IsDate(dateValue) Then
          IsoDateString = Right ("000" &  Year (dateValue), 4) & "-" & _
                          Right (  "0" & Month (dateValue), 2) & "-" & _
                          Right (  "0" &   Day (dateValue), 2)
       Else
          IsoDateString = "0000-00-00"
       End If
    End Function
    'Name       : IsoTimeString -> Generate an ISO time string from a date/time value.
    'Parameters : dateValue     -> Input date/time value.
    'Return     : IsoTimeString -> Time part of the input value in "hh:mm:ss" format.
    Function IsoTimeString(dateValue)
       If IsDate(dateValue) Then
          IsoTimeString = Right ("0" &   Hour (dateValue), 2) & ":" & _
                          Right ("0" & Minute (dateValue), 2) & ":" & _
                          Right ("0" & Second (dateValue), 2)
       Else
          IsoTimeString = "00:00:00"
       End If
    End Function
    'Name       : LogMessage -> Writes a message to a log file.
    'Parameters : logPath    -> String containing the full folder path and file name of the Log file without with file extension.
    '           : message    -> String containing the message to include in the log message.
    'Return     : None       ->
    Function LogMessage(message)
       If Not LogToCentralFile(scriptLogPath & ".csv", IsoDateTimeString(Now) & "," & message) Then
          Exit Function
       End If
    End Function
    'Name       : LogError -> Writes an error message to a log file.
    'Parameters : logPath  -> String containing the full folder path and file name of the Log file without with file extension.
    '           : message  -> String containing a description of the event that caused the error to occur.
    'Return     : None       ->
    Function LogError(message)
       If Not LogToCentralFile(scriptLogPath & ".err", IsoDateTimeString(Now) & "," & BuildError(message)) Then
          Exit Function
       End If
    End Function
    'Name      : BuildError -> Builds a string of information relating to the error object.
    'Parameters: message    -> String containnig the message that relates to the process that caused the error.
    'Return    : BuildError -> Returns a string relating to error object.  
    Function BuildError(message)
       BuildError = "Error " & Err.Number & " (Hex " & Hex(Err.Number) & ") " & message & ". " & Err.Description
    End Function
    'Name       : LogToCentralFile -> Attempts to Appends information to a central file.
    'Parameters : logSpec          -> Folder path, file name and extension of the central log file to append to.
    '           : message          -> String to include in the central log file
    'Return     : LogToCentralFile -> Returns True if Successfull otherwise False.
    Function LogToCentralFile(logSpec, message)
       Dim attempts, objLogFile
       LogToCentralFile = False
       'Attempt to append to the central log file up to 10 times, as it may be locked by some other system.
       attempts = 0
       Do
          On Error Resume Next
             Set objLogFile = objFSO.OpenTextFile(logSpec, ForAppending, True)
             If Err.Number = 0 Then
                objLogFile.WriteLine message
                objLogFile.Close
                LogToCentralFile = True
                Exit Function
             End If
          On Error Goto 0
          Randomize
          Wscript.sleep 1000 + Rnd * 100
          attempts = attempts + 1
       Loop Until attempts >= 10
    End Function
    'Name       : PromptScriptStart -> Prompt when script starts.
    'Parameters : None
    'Return     : None
    Function PromptScriptStart
       MsgBox "Now processing the " & DQ(Wscript.ScriptName) & " script.", vbInformation, scriptBaseName
    End Function
    'Name       : PromptScriptEnd -> Prompt when script has completed.
    'Parameters : None
    'Return     : None
    Function PromptScriptEnd
       MsgBox "The " & DQ(Wscript.ScriptName) & " script has completed successfully.", vbInformation, scriptBaseName
    End Function
    Thanks

    Here is a script that will copy the previous days events and save them to "C:\". The file name be yesterdays date ex "04-18-2010-Events.csv"
    Const strComputer = "."
    Dim objFSO, objWMIService, colEvents, objEvent, outFile
    Dim dtmStartDate, dtmEndDate, DateToCheck, fileDate
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
    Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")
    'change the date form "/" to "-" so it can be used in the file name
    fileDate = Replace(Date - 1,"/","-")
    Set outFile = objFSO.CreateTextFile("C:\" & fileDate & "-Events.csv",True)
    DateToCheck = Date - 1
    dtmEndDate.SetVarDate Date, True
    dtmStartDate.SetVarDate DateToCheck, True
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colEvents = objWMIService.ExecQuery _
    ("Select * from Win32_NTLogEvent Where TimeWritten >= '" _
    & dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'")
    For each objEvent in colEvents
    outFile.WriteLine String(100,"-")
    outFile.WriteLine "Category = " & objEvent.Category
    outFile.WriteLine "ComputerName = " & objEvent.ComputerName
    outFile.WriteLine "EventCode = " & objEvent.EventCode
    outFile.WriteLine "Message = " & objEvent.Message
    outFile.WriteLine "RecordNumber = " & objEvent.RecordNumber
    outFile.WriteLine "SourceName = " & objEvent.SourceName
    outFile.WriteLine "TimeWritten = " & objEvent.TimeWritten
    outFile.WriteLine "Type = " & objEvent.Type
    outFile.WriteLine "User = " & objEvent.User
    outFile.WriteLine String(100,"-")
    Next
    outFile.Close
    MsgBox "Finished!"
    v/r LikeToCode....Mark the best replies as answers.

Maybe you are looking for

  • Can I have a second, external HD with a higher OS than my main drive?

    I've started to come across a few programs that need OS X 10.4 or higher to run. I have a beautifully stable system with 10.2.8, and I hate to mess that up, especially since my internal CD drive has stopped running, and am using an external CD/DVD dr

  • HDV outputting to SD DVD... +  mixing with XDCAM

    Hi Earlier this year we shot a documentary on a Sony PDW-F350L HD XDCam (great camera, stunning footage - 35Mbps). Working in FCP has been fine. We're doing a follow up and budget and logistics dictate that we sadly can't use 350s again (where we're

  • Guest password in e-2500

    I've set a password for the guest wireless account however when connecting a computer to it It is not asking for the password.  No simular problems with the regular 2.4 and 5Gb settings.  And no, it's not an issue of the PC storing the password.  Thi

  • OAF: Error:Developer Mode Error: Cannot Display Page

    Hi Everyone, When i click on button it shows me the below error: "You cannot complete this task due to a loss of page data. Cause: This error has been encountered because the SESSION_TIMEOUT_RECOVERY_ENABLED profile option value was set to "No" when

  • How to approach learning Flash

    I Posted this in the Dreamweaver forum also, because I am taking classes in both subjects, so here is my current situation and question: My progress on my own has been a crock. I'm a hack at html, a prisoner in beginning Dreamweaver and a dunce at Fl