• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 637
  • Last Modified:

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!
0
YoungBonzi
Asked:
YoungBonzi
  • 5
  • 3
  • 2
  • +3
2 Solutions
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now