1.

Solve : Move files from multiple source dirs using wildcards?

Answer»

Who knows a good method to copy/move/delete specific file names from multiple source dirs using wildcards?

I need something like (e.g.):
move "C:\mydir\bogus ?\*A*" C:\dest\
to move only files "*A*" from many "bogus " dirs (e.g. bogus 1, bogus 2, bogus n) etc.
Obviously the above command doesn't work and MSDOS seems not to understand wildcards in the path names...
Something with that syntax does work INSTEAD on unix-like OS (as well as AmigaOS )...

Someone can help me?try this code out, worked for me well.


just replace "C:\destination\of files\" for the path you want
and the "C:\path of files\" well you get the point
Code: [Select]@echo off
cd c:\path of files\
for /f "tokens=*" %%a in ('dir /b /W "bogus *"') do (
cd "%%a"
copy "*a*" "c:\tests\*a*"
cd ..
)Mmmh... interesting idea.... thank you!

I'v found a faster solution anyway with no need of creating a batch file:
for /R "C:\mydir" %a IN (*A*) DO copy "%a"

There are some limits though in this case: /R "C:\mydir" enters recursively ALL dirs, not only "Bogus *" ones.I've also been told that using PowerShell with Vista and Win7 this simple command (Unix-like) works without troubles:
mv "C:\mydir\bog*\*A*"

Confirmed. It works FINE. PowerShell is definitely much better than old MSDOS: http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx freely available for Windows XP Service Pack 2, Windows Server 2003, Windows Vista and Windows Server 2008. The .NET FRAMEWORK 2.0 is required (not needed if you have Vista).



Discussion

No Comment Found