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
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

BAT file 'for each' command

  • 07-02-2008 7:31pm
    #1
    Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭


    I want to copy every text file from one directory to another then delete all the files in the original directory
    This will do it:
    copy "E:\dirA\*.txt" "E:\dirB\"
    del "E:\dirA\*.txt"

    but if any .txt files get put into dirA between the two commands then they will be lost as they wouldn't be copied.
    So I really need to copy and delete them one at a time. Anyone have any ideas how to go about doing that?


Comments

  • Registered Users, Registered Users 2 Posts: 1,258 ✭✭✭carveone


    I want to copy every text file from one directory to another then delete all the files in the original directory
    This will do it:
    copy "E:\dirA\*.txt" "E:\dirB\"
    del "E:\dirA\*.txt"

    but if any .txt files get put into dirA between the two commands then they will be lost as they wouldn't be copied.
    So I really need to copy and delete them one at a time. Anyone have any ideas how to go about doing that?

    Windows XP has extended the batch file command set rather but...
    The old way would be:

    cd e:\dirA
    for %a in (*.txt) do c:\temp\copydel %a e:\dirB

    and then have a batch file called copydel.bat that takes two
    arguments etc etc...

    Or just use "move"!!!

    move e:\dira\*.txt e:\dirb

    Conor.


  • Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭Mr. Flibble


    Cheers carveone. I was copying over different drives so I just presumed move would copy them. But it does delete the old files too, so that works great. Thanks.


Advertisement