GroupDocs.Metadata for Java

Update Metadata From Vsx File In Java

Metadata Editor for Java applications – Change metadata fields from all popular documents, images and multimedia file formats using metadata editor API for Java.

Steps for Updating Metadata to Vsx in Java

GroupDocs.Metadata for Java makes it easy for Java developers to edit metadata details to Vsx files from within their applications by implementing a few easy steps.

  1. Load the Vsx file to be updated
  2. Specify a predicate that will be used to filter desired metadata properties.
  3. Pass the predicate and the new value to the UpdateProperties method.
  4. Save the changes.
Copy
// Edit VSX creation date metadata
public class UpdatingMetadata
{
  public static void run() 
  {
    Date threeDaysAgo = new Date(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(3));
    try (Metadata metadata = new Metadata("input.vsx"))
    {
        // Update the file creation date/time if the existing value is older than 3 days
        int affected = metadata.updateProperties(new ContainsTagSpecification(Tags.getTime().getCreated()).and(
                new OfTypeSpecification(MetadataPropertyType.DateTime)).and(
                new UpdatingMetadata().new DateBeforeSpecification(threeDaysAgo)), new PropertyValue(new Date()));

        // Process updation result
        System.out.println(String.format("Affected properties: %s", affected));

        // Save edited file
        metadata.save("output.vsx");
    }
  }

  // Define your own specifications to filter metadata properties
  public class DateBeforeSpecification extends Specification
  {
    public DateBeforeSpecification(Date date)
    {
      setValue(date);
    }

    public final Date getValue()
    {
      return auto_Value;
    }

    private void setValue(Date value)
    {
      auto_Value = value;
    }

    private Date auto_Value;

    public boolean isSatisfiedBy(MetadataProperty candidate)
    {
      Date date = candidate.getValue().toClass(Date.class);
      if (date != null)
      {
        return date.before(getValue());
      }
      return false;
    }
  }
}
<dependencies> <dependency> <groupId>com.groupdocs</groupId> <artifactId>groupdocs-metadata</artifactId> <version>24.8</version> </dependency> </dependencies> <repositories> <repository> <id>repository.groupdocs.com</id> <name>GroupDocs Repository</name> <url>https://repository.groupdocs.com/repo/</url> </repository> </repositories>
click to copy
copied
More examples Documentation

Manipulate VSX Metadata for Java Apps

The GroupDocs.Metadata API lets developers easily update hidden metadata in various document formats in their Java applications. Apply, edit, search for, and remove metadata programmatically.

Metadata Configuration

Simple Metadata Integration

GroupDocs.Metadata simplifies adding different metadata to documents and files within your Java apps. Developers can effortlessly apply, update, or remove metadata.

Detailed Metadata Control

The API offers extensive options for customizing metadata. It is easy to find metadata in files using special requests and remove or update them.

Utilizing Native VSX Features

Depending on the document format, developers can leverage built-in metadata like EXIF for images. This might include information about photo like camera model and number, resolution, creation date and other.

Update the Lyrics tag in an MP3 file (Example)

This example demonstrates updating hidden metadata in MP# media-file.

Java


//  Load file to Metadata class constructor
try (Metadata metadata = new Metadata("input.mp3")) {
    MP3RootPackage root = metadata.getRootPackageGeneric();

    if (root.getLyrics3V2() == null) {
        root.setLyrics3V2(new LyricsTag());
    }

    //  Update lyrics data
    root.getLyrics3V2().setLyrics("[00:01]Test lyrics");
    root.getLyrics3V2().setArtist("test artist");
    root.getLyrics3V2().setAlbum("test album");
    root.getLyrics3V2().setTrack("test track");

    // You can add a fully custom field to the tag
    root.getLyrics3V2().set(new LyricsField("ABC", "custom value"));

    // Save result
    metadata.save("output.mp3");
}

About GroupDocs.Metadata for Java API

GroupDocs.Metadata for Java is an advanced metadata fields manipulation solution to easily read, add, modify, delete, search, compare, replace and export metadata information from images and document formats without using any external software. Edit metadata details from Word documents, Excel spreadsheets, PowerPoint presentations, Outlook emails, OneNote, Visio, Project, PDF, AutoCAD, ZIp, Audio and Video file formats along with the support for working with many other metadata processing features.
Learn more
About illustration

Ready to get started?

Download GroupDocs.Metadata for free or get a trial license for full access!

Changing Metadata Of Other File Formats

Multi format documents and images metadata editing API for Java. Retrieve metadata of some of the popular file formats as stated below

Temporary license tips

1
Sign up with your work email.
Free mail services are not allowed.
2
Use Get a temporary license button on the second step.
 English