Yeah, thx. Guess writing my own task would not have been a lot different but following your advice this does it for me (with a little simplification added by delting and copying rather than renaming [and ignoring different length of months which is more appropriate for my use case anyways]):

    <target name="all">
<copy file="Y:/tagebuch/itteerde.bib" todir="C:/daten/studium/01216 Kombinatorische Optimierung - Effiziente Graphenalgorithmen/uebungen/EinsendeAufgaben/EA01"/>

        <delete>
            <fileset dir="C:/daten/studium/Z_TODO" includes="*.ico"/>
        </delete>

        <script language="groovy">
            import java.io.File;
            import java.util.Date;
            import java.text.DateFormat;
            import java.text.SimpleDateFormat;
            import java.util.GregorianCalendar;
            import java.nio.file.Files;

            File todoDir = new File("C:/daten/studium/Z_TODO");
            File iconDir = new File("C:/daten/studium/Z_TODO/icons");
            Calendar calendar = new GregorianCalendar();
            calendar.setTime(new Date());
            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
            String today = formatter.format(calendar.getTime());
            calendar.add(Calendar.DAY_OF_MONTH,7);
            String oneWeek = formatter.format(calendar.getTime());;
            calendar.add(Calendar.DAY_OF_MONTH,23);
            String oneMonth = formatter.format(calendar.getTime());;
Files.copy(new File(iconDir.getPath()+File.separator+"zzz_today.ico").toPath(),new File(todoDir.getPath()+File.separator+today+ " zzz_today.ico").toPath()); Files.copy(new File(iconDir.getPath()+File.separator+"zzz_one week.ico").toPath(),new File(todoDir.getPath()+File.separator+oneWeek+ " zzz_one week.ico").toPath()); Files.copy(new File(iconDir.getPath()+File.separator+"zzz_one month.ico").toPath(),new File(todoDir.getPath()+File.separator+oneMonth+ " zzz_one month.ico").toPath());

        </script>
    </target>
Am 20.09.2014 um 18:51 schrieb Al Le:
> In directory $foo$ take file [\d\d\d\d-\d\d-\d\d zzz_today.ico] and
> rename it to <... something not trivial ...>

If I have to do something which I can't easily do with standard Ant tasks I use the script task, usually with JavaScript. There, you can do whatever computations you want and pass the result to the outer script via project properties. In you case this would be parsing a date computing (and formatting) another date. The rest (file moving in your case) is done with the standard ant tasks.



On 20.09.2014 16:13, Erik Itter wrote:
Hello,

I am trying to automate my environment a little more and thought to do
the following:

In directory $foo$ take file [\d\d\d\d-\d\d-\d\d zzz_today.ico] and
rename it to [yyyy-mm-dd zzz_today.ico] filling in the actual current
date. Further I'd like to rename another file [\d\d\d\d-\d\d-\d\d
zzz_one week.ico] to [yyyy-mm-dd zzz_one week.ico], obviously meaning
the actual current date plus seven days.

Guess I should be able to do it with some form of

<move todir="$foo$"...>
     <mapper type="regexp" .../>
</move>

but I am somewhat lost. I'd like to do it with the tasks provided if
possible instead of writing my own task. All kinds of help/ advice/
examples appreciated, of course.

thx, Erik

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to