Computer Hope
Microsoft => Microsoft DOS => Topic started by: dbam 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?
-
It sounds like what you need is actually something like this in a batch file:
for /f "tokens=*" %%a in ('dir D:\*somestring* /s /b') do move "%%a" C:\somedirectory
for the same command directly in a command prompt, change the %%a to just %a
-
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?
-
What are the percent signs telling the program to do?
To create and use variables.
-
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?
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.