This kind of thing is easy with a Unix shell. Here's what you could do with my own Hamilton C shell (including the free version.) You could do something very similar with Cygwin bash.
mv *\* .
If your directory is really huge, it's possible that could wildcard into too long a command line for Windows to pass to a child process. (The Windows CreateProcess call limits the argument list to 32K Unicode characters.) But the C shell has no limit internally, so you could iterate over the whole list this way:
foreach i ( *\* )
mv $i .
end
To @MarkAllen's point above, this kind of assumes there are no duplicate names. If there are, the later copies in the list will overwrite the older ones. If that's a concern, you could iterate over the files, mv
'ing them only if you're not overwriting. The :t
operator is the tail operator. The -e
operator is the file exists test.
foreach i ( *\* )
if ( -e $i:t ) then
echo -2 $i not moved because it already exists
else
mv $i .
end
end
This still leaves the empty directories, which maybe you don't want after they've been emptied. That could be the next iteration if it mattered.