Not adventure related (well, it's a puzzle, about xcopy)

Started by DutchMarco, Sat 02/04/2011 15:57:14

Previous topic - Next topic

DutchMarco

Forgive me for asking this question, but I didn't know where else to ask.

I want to copy a whole bunch of files with a given extension (say, *.txt) from a dir structure into a single directory, leaving out the directory structure.
Say,the files are in D:\aa\aab\*.* and aa\aac\*.* etc and I wanted to copy all *.txtfiles to c:\yaddayadda. I tried xcopy, but it does copy all the aab and aac directories, which I obviously don't want. I don't know how else to do this / what tool to use. BTW I'm on XP, not Windoze 6 or 6.1 (aka 7).

Since these are 40 files I don't want to do this by hand.

Calin Leafshade

#1
How about this:

Code: ags

for /R %f in (*.*) do copy /Y "%f" .\%~nxf


that will copy all the files from the subdirectories of your current folder into the root of your current folder.

Edit: actually i guess you should put the second term in quotes too.. although might not be needed

Code: ags

for /R %f in (*.*) do copy /Y "%f" ".\%~nxf"

Babar

I'm not sure what language Calin is suggesting (oh, he tells me it is a dos command), but the way I do it, is using winrar, and then setting it to "Do not store paths" in the advanced options. After it is all archived, you can unrar it wherever you want.
Probably more convoluted than Calin's method, but it works :D.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

DutchMarco

Quote from: Babar on Sat 02/04/2011 17:22:52
I'm not sure what language Calin is suggesting (oh, he tells me it is a dos command), but the way I do it, is using winrar, and then setting it to "Do not store paths" in the advanced options. After it is all archived, you can unrar it wherever you want.
Probably more convoluted than Calin's method, but it works :D.
Thanks you all!  Yeah, I guess Calin's command would be what you'd put in a batch file, I hadn't even thought of that! Instead of going by WinRAR (which is quite a cumbersome method), I used Explorer² by Zabkat (brilliant program, BTW!), I searched for all files with a given extension, and from the resulting resultset I copied all files , by mouse, but in one go into a new dir. Not the ideal approach (to me that would be command line), but it worked.

Thanks anyway for your advice!

Calin Leafshade

You don't need to put it in a batch file. You could do that command straight from the command line.

DutchMarco

Quote from: Calin Leafshade on Sun 03/04/2011 13:18:02
You don't need to put it in a batch file. You could do that command straight from the command line.
Wow, I never knew there was a command called "for", I'll keep that in mind, could come in handy!

zabnat

If you type "help" in you'll find out what basic commands are available. Also "help for" will help you if you need to refresh your memory how the "for" command works. :)

DutchMarco

I reserved the right to type "xcopy /?"After all, xcopy is/was a DOS-tool, so if it doesn't display sufficient documentation with that command, it should just get hold of some "man" pages.  or learn to live with it.

(duh, don't I mean that I should  learn to live with... nah.)

Khris

Another way would have been to search for all *.txt files in the main dir using Windows' search window, then cut and paste them.

zabnat

Quote from: Khris on Mon 04/04/2011 20:35:41
Another way would have been to search for all *.txt files in the main dir using Windows' search window, then cut and paste them.
Yes, but in that way there is no puzzle. Afterwards you wouldn't really get that feel of accomplishment that you get after researching and solving a hard puzzle. ;D

Khris

True, just thought I'd mention it in a thread that makes fun of the one actually decent OS by Microsoft besides XP :)

DutchMarco

Quote from: Khris on Tue 05/04/2011 08:43:52
True, just thought I'd mention it in a thread that makes fun of the one actually decent OS by Microsoft besides XP :)
Which one would that be?You're not talking about DOS, are you? In all fairness, DOS was not a decent OS - no multitasking/-threading, poor security, etc. Good gaming though. And I solved teh problem by using a search in Explorer², the program that makes file management in Windoze pleasant. So a workaround that was't much of a puzzle (the bigger puzzle would have been to install Linux, and write a bash-script to do that - a much more challeniging puzzle, but with hopefully more satisfying outcome).

Khris

No, not DOS, I was of course talking about Windows ME.

I use TotalCommander, the hands down best file management app in existence. The last time I opened an Explorer window was when I copied big files from one HD to another in TC and didn't want to send the copy window to the background because I wanted to be able to check the progress closely. Wait, no, I simply ran a second instance of TC :)

SMF spam blocked by CleanTalk