Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to extract certain file types from complex folder structure?

Posted on 2010-09-01
6
Medium Priority
?
792 Views
Last Modified: 2013-11-10
Hi,
I've a "complex", deep foldere structure on Win7 and want to extract - recursively - all JPEG, all PDFs etc. from this structure and store all to a separate folder. I'm sure this can be done with a small command shell script, but how?
Regards
0
Comment
Question by:go4java
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 58

Accepted Solution

by:
Bill Prew earned 1000 total points
ID: 33575777
If you  want to preserve the directory structure, then you can do this with several xcopy commands, like:

xcopy /s /i c:\source\*.jpg d:\dest

If you want to flatten into a single directory, then this approach can be used in a BAT file:

@echo off
for /F "tokens=*" %%A in ('dir /a-d /b /s "c:\source\*.jpg"') do copy "%%~fA" "d:\dest\%%~nxA"

If you want to add another powerful file copy tool to your toolbox then get a copy of ROBOCOPY from Microsoft (link below that includes the utility) and take a look at it, it can do what you want with a single command but syntax takes a while to learn.

http://technet.microsoft.com/en-us/magazine/2006.11.utilityspotlight.aspx

If you have more than just a couple of extensions you want to copy then we could add a small loop around either of the above first two approaches to process each extension.  An example of this approach can be found in this prior question:

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/XP/Q_24889370.html

Hope this helps,

~bp
0
 
LVL 3

Assisted Solution

by:ola_erik
ola_erik earned 1000 total points
ID: 33576133
never mind the scripting

get Total Commander
go to the top folder
search for extension and include all subfolders
go to pane
move all hits in pane to some folder

repeat

To preserve the structure, use Xcopy as stated before
0
 
LVL 14
ID: 33577411
@ola why woudl you use TCommander which must be downloaded and installed and I believe paid for, when there is a perfect solution already availabel natively in the operating system for free and the task itself is obviously perfect for a script?

@Go4JavaI would have written a script almost exactly as Bill did, I think you should go with his methods.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 5

Expert Comment

by:artoaperjan
ID: 33577589
Hi
if you are going to do this only once or once in a year than use the simple search with windows.
if you are going to do this every day then scripting.

if you are going to use the windows search then search the top folder for the extention for example *JPEG and it will find all the files just select them and move them to where you want.
0
 
LVL 14
ID: 33577691
@art windows search is painfully time consuming if:

1. you are running the classic search (Win XP/2003 and prior)
2. you are running in an unindexed location
3. and IMO even the live search for old versions of windows is really pretty slow. (Honestly I have an issue witht the speed of the search even in Vista.  I think only 7 gets it right.)

ALSO: Using the Windows OS File Copy feature (and the MOVE feature when between different hard disks) requires a lot of additional useless overhead to calculate transfer times and speeds, the script will be much faster.

Also and I knwo here I'm just splitting hairs, but, he didn't mention which MS OS he is running under, it's possible he may even be doing this in MSDOS as he tagged it..  Though I imagine he's probably on XP, 2k3, or 7..
0
 
LVL 58

Expert Comment

by:Bill Prew
ID: 33578196
Thanks, glad that was helpful.

~bp
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Simple Linear Regression
Introduction to Processes

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question