free web page hit counter

How To Extract Files From Multiple Folders At Once


How To Extract Files From Multiple Folders At Once

So, there I was, drowning in a sea of folders, each one stuffed to the brim with files. I was on a mission to extract a specific type of file - let's say, JPEG images, for argument's sake. I could've spent hours clicking through each folder, one by one, but who's got time for that, right? Not this gal. I needed a faster way to extract files from multiple folders at once.

Enter the Command Line

Now, before you roll your eyes and mutter something about command lines being for tech geeks only, hear me out. The command line is like your secret weapon for tasks like this. It's fast, it's efficient, and it's not as scary as it sounds. I promise.

Meet the find command

The find command is your new best friend. It's like having a tiny, obedient elf who'll scour your folders for exactly what you're looking for. Here's how you use it:

find /path/to/your/folders -name '.jpg' -exec cp {} /path/to/destination/folder \;

Let's break it down, shall we?

How To Extract Files From Multiple Folders in Windows - YouTube
How To Extract Files From Multiple Folders in Windows - YouTube
  • /path/to/your/folders - Replace this with the path to the folders you want to search in.
  • -name '.jpg' - This tells find to look for files ending with .jpg. You can replace this with any file extension you're looking for.
  • -exec cp {} /path/to/destination/folder \; - This tells find to copy (cp) the files it finds to the destination folder you specify.

See? Not so bad, huh? And the best part? You can replace cp with mv if you want to move the files instead of copying them.

But what if I want to extract files from subfolders too?

No problemo! Just add the -type f flag to your command. This tells find to only look in files, not directories. Here's how it looks:

find /path/to/your/folders -type f -name '.jpg' -exec cp {} /path/to/destination/folder \;

How to Extract Files from Multiple Folders in Windows 11 | Move
How to Extract Files from Multiple Folders in Windows 11 | Move

And voila! Your command will now search through all subfolders too. Isn't that neat?

Bonus Round: Using rsync

If you're feeling adventurous, you can also use rsync to copy files from multiple folders. It's a bit more complex, but it's also more powerful. Here's a basic example:

How to Extract Multiple Zip Files at Once - Online Computer Tips
How to Extract Multiple Zip Files at Once - Online Computer Tips

rsync -avh --include='/' --include='.jpg' --exclude='' /path/to/your/folders/ /path/to/destination/folder

This command will copy all .jpg files and empty directories from your source folders to your destination folder. The --include and --exclude flags are what make this work. They tell rsync to include only the files and directories you want, and exclude everything else.

Pretty nifty, huh? And you thought command lines were just for tech nerds. Well, now you're one too. Congratulations! 😉

You may also like