Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7181803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:38:02+00:00 2026-05-28T17:38:02+00:00

I am unable to run the code for moving file, when i use the

  • 0

I am unable to run the code for moving file, when i use the ant macrodef attribute in groovy task inside the macrodef.

<macrodef name="dirmove">
            <attribute name="todir" />
            <attribute name="fromdir" />
            <attribute name="includes" default="*" />
            <sequential>
                <var name="todir" value="@{todir}" />
                <var name="fromdir" value="@{fromdir}" />
                <var name="includes" value="@{includes}" />
                <groovy>
                File dir1 = new File(properties.'fromdir');
                File dir2 = new File(properties.'todir');  
                def pattern = properties.get('includes')
                println pattern;
                dir1.eachFileMatch  ~/pattern/, { 
                    f-> 
                    boolean fileMoved = f.renameTo(new File(dir2, f.getName()));
                    //assert f.name == '1.txt' //**because File object is immutable, so I am just checking for the existing of previous file name. It is still there.
                    println fileMoved;
                }
            </groovy>
        </sequential>
    </macrodef>

This code correctly prints the value of pattern, which is coming from attribute value. But the eachFileMatch function doesn’t picks up the spec

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:38:04+00:00Added an answer on May 28, 2026 at 5:38 pm
                dir1.eachFileMatch  ~/pattern/, { 
    

    should be

                dir1.eachFileMatch  ~/${pattern}/, { 
    

    As pattern is a String variable, so you need to add it in to the regex pattern as such.

    Previously, you were just searching for all files called pattern

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use an alarm to run some code at a certain time.
I am unable to run my code in debug using gdb because of the
I'm unable to run any selenium tests since I updated Firefox to 3.6. Is
Since moving to ADK14, I have been unable to build new apks for release
I have run across code that invokes a function as fn(a,b,c) but the definition
After installing CodeCollab on OS X 10.6, I get Error: Unable to run ccollabgui
I run php test_code.php I get PHP Warning: PHP Startup: Unable to load dynamic
I have run the following code in this page RsyntaxTextArea using Java and i
When I run my code through the version 252 checker binary, there are no
When I try to run this code it force closes. And I apologize in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.