Move all files with pattern in filename

Well.

I would love to have a way to:

1.) search a folder, lets say: X:\Files
for any file that contains a "Conflict" in its filename (only!)
(recursively so it searches the whole contents of the folder)
2.) Move all files to another Folder.

All this under DOS.

Any help is appreciated.

The built in windows command Find or FindStr mirrors the capabilities of the Unix command Grep.

'dir /B /S' will list all the files, and I gues /A-D to avoid directories.

I guess you could put them in a file and drive edit to convert the file into a bat full of copy commands.

You could get CygWin or the msdos gnu-like commands. UNIX Command Line Tools For MS-Windows XP / Vista / 7 Operating Systems

Ok, so supposing I listed the files the way you said...

What would I then need to add in order to move the found files to another dir ?

xargs doesn't exist under windows so...

To ensure reliability, copy one file per line:

copy <original_line> target_dir

Cygwin definitely has xargs and bash while read. I am not sure how close the others get. I bet you could put Cygwin on a flash drive and run it anywhere, despite the registry. Cygwin is essentially invoked as bash and everything unix-like happens inside there. Cygwin installs pretty simply if you have broadband. I use it a lot.

So essentially what you are saying is:

The thing I want to do is not possible under windows alone without cygwin ?

Meh too bad.

Thanks anyways.

You can get busybox for windows which will have most of the usual commands contained in one exe file. No installation necessary at all.

1 Like

Never say never. Driving edit with script might work. PERL is another direction that can help, but that's pretty close to going with VB, C, C++, JAVA. Busybox looks very interesting: BusyBox - The Swiss Army Knife of Embedded Linux

I got the w32 binary version of busybax, and it works really nice: http://dl.dropbox.com/u/5943991/busybox-w32/busybox.exe