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
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

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

  • 02-04-2012 09:56PM
    #1
    Registered Users, Registered Users 2 Posts: 5,103 ✭✭✭


    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

  • Registered Users, Registered Users 2 Posts: 22,575 ✭✭✭✭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, Registered Users 2 Posts: 5,103 ✭✭✭mathie


    Steve wrote: »
    Try this:


    source.

    You sir are a legend!
    thanks


Advertisement