Copying Files

Hello,

I need to copy files out of many folders into one folder.

I have:

dir1\1.jpg
dir1\2.jpg
dir2\a.jpg
dir2\b.jpg
...
dir100\zxcv.jpg
dir100\asfdzxcv.jpg

that all need to go into one final directory.

Does anyone know how I can do this? I'm willing to play around with any batch files, php, or C++ code you can supply. Or any other ideas would be a help too.

Thank you!
LVL 8
YoungBonziAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sam PanwarSr. Server AdministratorCommented:
step :1

Create a document on your desktop with a .bat extension. (i.e. copy.bat) The document can contain the COPY or XCOPY  DOS command. Ex:

Copy c:\dir1\1.jpg d:\dir\1.jpg
Copy c:\dir1\2.jpg d:\dir\2.jpg
Copy c:\dir1\a.jpg d:\dir\a.jpg
Copy c:\dir1\b.jpg d:\dir\b.jpg


save file

and run batch file

you can also secduke this from the following oprion so its run on the time which you decide
Step 2.
Open Scheduled Tasks from Start Menu, Accessories, System Tools. Double-click Add Scheduled Task
and add the that batch file and adjust time at you want run the schedule .
0
Nick DennyCommented:
If the directories are all in 1 sub directory, and its all the files you want, a simple batch file using xcopy will do it with the appropriate parameters:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true

e.g.
cd [top of directory tree]
xcopy *.* [destination drive]:\[destination directory]\[folder] /d /e /h /i /k /y /r /x

And also, if you want all the same file extensions from all over the directory structure then the same applies.

cd [top of directory tree]
xcopy *.jpg [destination drive]:\[destination directory]\[folder] /d /e /h /i /k /y /r /x

However, if there are other files in the directories you dont want, or you don't want all the jpg's then this won't work.

But if space allows, copy everything then delete what you don't want with simple sorting (if that would be practical).

Or have I totally misunderstood?? Sorry if thats the case.
0
victornegriCommented:
Robocopy is also a great tool you can use that has MANY MANY MANY options for customized copies. It's part of the Windows 2000/2003 Server Resource Kit. I think there's a switch to copy all files (regardless of folder) and place them in a flat folder -- if that's what you want. Worth exploring.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

YoungBonziAuthor Commented:
I think I should specify that I am looking for an automated way to do this, in very few lines of code.

The directory is C:\pics. In it are dozens of subdirectories. In those are jpeg files. I need to copy all the jpegs in the c:\pics subdirs into a single folder, i.e., C:\allpics. In C:\allpics there should not be any subdirectories, only jpegs.


victornegri, I tired robocopy, but I'm afraid it can't do it either. Here are a list of the options: http://www.ss64.com/nt/robocopy.html

The closest I could get with that was: robocopy C:\pics C:\xpics *.jpg /s

But it actually just replicates c:\pics in c:\xpics, subdirs and all. Same goes for xcopy, both seem to have the same flags.
0
JamesMylerCommented:
Use windows search in the root Pics dir and then select all files and cut and paste into your new dir
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nick DennyCommented:
My way works for that.

Copy and paste this into notepad and save as    xxxx.bat

echo off
c:
cd \pics
xcopy *.jpg c:\allpics /d /e /h /i /k /y /r /x
exit

This will copy all of them into one - exactly as you said.

You can run this batch file from anywhere on your system and as mentioned even add it into scheduled tasks.
0
Nick DennyCommented:
oops sorry

this will also copy the directory structure.
0
Nick DennyCommented:
aha - heres what you need:

http://www.xxcopy.com/index.htm

there is a parameter /SG that copies the files into just the one directory.
0
YoungBonziAuthor Commented:
Thank you both! Both ways work great, but you have to love the JamesMyler answer, LOL.
0
sunilcomputerCommented:
Follow the Steps to get it done in 10 Seconds :-

  1. Open the folder C:\Pics      using My Computer
  2. Press F3
  3. Click Files and Folders                                              (If it's Windows XP else skip this step)
  4. Click "Search Now"
  5. Click twice on the Top Row where "Name" is written   (This will Arrange files and folders seperately)
  5. Select all Files shown in Right Side Window                (Don't Select Folders shown at last)
  6. Copy and Paste them to C:\Allpics

Enjoy :)
0
Nick DennyCommented:
@ youngbonzi - thanks - and yes - JamesMyler answer - very simple but... automated????
0
YoungBonziAuthor Commented:
Sorry, I meant automated as in not having to go in to each directory to grab the pictures.
0
JamesMylerCommented:
If this is something that you will be doing on a regular basis you should look into a macro recorder which can be purchased for around $25 to $30 USD. Similar to the old windows recorder. I have not been able to find any free versions. Both ways work, just depends if you are GUI or CLI motivated.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Operating Systems

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.