Advertisement
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 08: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