Hello,
That's basically what I tried actually, but I am facing an issue where the line
jpgFile  = new java.io.File(source);
does not reference the file I want because:

1. I miss the source folder. As an example task:
<copy todir="C:\A">
<fileset dir="C:\B" includes="*.JPG" />
<mapper... />
</copy>
Here, the variable "source" would be something matched by *.JPG. It
does not include the folder C:\B.

2. There might be previous mappers that changed the filename.

My question was more to know if there was anyway to access the source
File object *directly* from a mapper.
Something like
public File getSourceFile();
would be perfect ;)

Thanks anyways.

Patrick

On 12/11/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
As the manual sais about file mappers [1], you have to implement
org.apache.tools.ant.util.FileNameMapper [2]. Basically to setters for your own
parametrization and - most important - the map-method

    /**
     * Returns an array containing the target filename(s) for the
     * given source file.
     *
     * <p>if the given rule doesn't apply to the source file,
     * implementation must return null. SourceFileScanner will then
     * omit the source file in question.</p>
     *
     * @param sourceFileName the name of the source file relative to
     *                       some given basedirectory.
     * @return an array of strings if the ruld applies to the source file, or
     *         null if it does not.
     */
    String[] mapFileName(String sourceFileName);


With Ant 1.7 you could also use a <scriptmapper>:

  <scriptmapper language="javascript">
    jpgFile  = new java.io.File(source);
    exifName = getNameByExifInfo( jpgFile );  // your work ;-)
    self.addMappedName( exifName );
  </scriptmapper>



Jan


[1] http://ant.apache.org/manual-rc/CoreTypes/mapper.html
[2] 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/FileNameMapper.java?view=markup


>-----Ursprüngliche Nachricht-----
>Von: Patrick Martin [mailto:[EMAIL PROTECTED]
>Gesendet: Freitag, 8. Dezember 2006 18:14
>An: Ant User
>Betreff: Access source file from mapper
>
>Hello,
>
>I am trying to develop a file name mapper which modifies the
>file name according to the file content.
>The idea is to map JPEG file names according to the image EXIF
>attributes (date, size, ...).
>
>The issue I encounter is that the mapper does not have access
>to the source File object, and thus cannot read the file. Is
>there a way around this?
>
>I would like to avoid *looping* (ant-contrib <for>) on source
>files, getting their respective EXIF attributes and
>copying/renaming accordingly...
>
>Thanks,
>
>Patrick
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED] For
>additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to