Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: dir piped to move command failure [solved]  (Read 2152 times)

0 Members and 1 Guest are viewing this topic.

dbam

    Topic Starter


    Greenhorn

    dir piped to move command failure [solved]
    « on: March 04, 2008, 08:26:52 PM »
    A command window in WinXP Pro given the instructions:

    dir D:\*somestring* /S | move C:\somedirectory

    What would happen to the files found by dir in the D drive?

    The idea was to find all files in D with "somestring" in the name and move them all collectively to the directory in C drive. The result was that the directory in C vanished (complete with all contents) to never-neverland. So, obviously this was not the correct way to pipe the results of the search to the move command.

    What would be the right way?

    « Last Edit: March 05, 2008, 11:01:27 AM by dbam »

    GuruGary



      Adviser
      Re: dir piped to move command failure
      « Reply #1 on: March 04, 2008, 10:04:09 PM »
      It sounds like what you need is actually something like this in a batch file:
      Code: [Select]
      for /f "tokens=*" %%a in ('dir D:\*somestring* /s /b') do move "%%a" C:\somedirectoryfor the same command directly in a command prompt, change the %%a to just %a

      dbam

        Topic Starter


        Greenhorn

        Re: dir piped to move command failure
        « Reply #2 on: March 04, 2008, 10:24:23 PM »
        Quote
        for the same command directly in a command prompt, change the %%a to just %a
        Thanks for the reply.
        What are the percent signs telling the program to do?
        Also, any idea what the command I used did with the directory that vanished? Is it forever gone?

        Dias de verano

        • Guest
        Re: dir piped to move command failure
        « Reply #3 on: March 04, 2008, 11:47:16 PM »
        What are the percent signs telling the program to do?

        To create and use variables.


        dbam

          Topic Starter


          Greenhorn

          Re: dir piped to move command failure
          « Reply #4 on: March 05, 2008, 10:58:56 AM »
          Quote
          A command window in WinXP Pro given the instructions:

          Code: [Select]
          dir D:\*somestring* /S | move C:\somedirectory
          Quote
          What would happen to the files found by dir in the D drive?

          Alas, it moved "C:\somedirectory into my home directory lock, stock and barrel, complete with the *somestring* files that it found. My guess is that it didn't know where else to put it since I didn't specify.

          Thanks Gary and Dias for the pointers and good help.