views:

112

answers:

3

This is what I have:

for /R %i in (*.swf) do copy %i C:/testfolder/

I get the error "The system cannot find the file specified.

It's finding the .swf's just fine, but it's not copying them.

A: 

Use Powershell.

See Example 1 — it is relative to your problem.

z-boss
While a nice suggestion this is overkill for something such simple. That's like all the folks who suggest installing cygwin for every minor problem in cmd.
Joey
A: 

You could use xcopy with the excludes argument (if you know what other types of files are present):

xcopy C:\sourcedir C:\destdir /EXCLUDE:excludes.txt /e

Where excludes.txt has a pattern of files not to copy on each line:

.svn
.obj
.js
Boiler Bill
This will copy the directory structure too, though. From what the OP attempted this isn't what s?he wants.
Joey
Yes this would not work as I do not need the directory structure or want to have to exclude other file types.Simply search for all SWF files within a Folder/SubFolders and copy those to a separate folder.
brewern
+1  A: 

You probably want to put the argument to copy in quotes as well as use backslashes:

for /R %i in (*.swf) do copy "%i" C:\testfolder\

(though I seriously wonder why you're playing around in the root directory of the drive).

And remember to double the % if you're using that in a batch file.

Joey
I'm on Windows XP, testing it from the command line first. Not in the root, I'm actually running this from a path, but omitted the folder due to client privacy. I'm getting "The syntax of the command is incorrect."
brewern