1.

Solve : dir piped to move command failure [solved]?

Answer»

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?

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 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? Quote from: dbam on MARCH 04, 2008, 10:24:23 PM
What are the percent signs telling the program to do?

To CREATE and use variables.

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.


Discussion

No Comment Found