Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

'for' command doesn't work in a batch file

Options
  • 02-04-2012 9:56pm
    #1
    Registered Users Posts: 5,099 ✭✭✭


    Hi

    I have a windows command which works from the command prompt

    for /r C:\Temp\test1 %i in (*.txt) do @move "%i" "C:\Temp\test2"

    It moves all the .txt files in C:\Temp\test1 (and subfolders) into C:\Temp\test2

    But when I put the file into a batch file it doesnt work

    any ideas?

    thanks
    m


Comments

  • Moderators, Category Moderators, Entertainment Moderators, Sports Moderators Posts: 22,584 CMod ✭✭✭✭Steve


    Try this:
    To use the FOR command in a batch program, specify %%variable instead of %variable. Variable names are case sensitive, so %i is different
    from %I.

    source.


  • Registered Users Posts: 5,099 ✭✭✭mathie


    Steve wrote: »
    Try this:


    source.

    You sir are a legend!
    thanks


Advertisement