Copy all subfolders . jpg to a single folder by cmd

Asked

Viewed 2,414 times

2

I have a folder that has 148 folders contained in it, and in each of these folders they have a file .jpg. I need to get all these .jpg and put into a single folder

cada pasta tem pelo menos 1 .jpg

I can do that in the Linux thus

   `#!/bin/bash

for arquivo in `find Origem -name *.jpg`; 
   do mv "$arquivo" Destino;
    done;

but I can’t reproduce that in Windows. Only the command find that I can reproduce the same result: dir /S /B *.jpg

  • Could do by the same explorer. Search *.jpg in the upper left corner, it will show all of that folder "inside". Then you give a control X (or control C) and glue the destination.

  • but I need to do it automatically but found a solution for /r %d in (*.jpg) from copy /Y "%d" "C: Users IRINEU Desktop a b"

2 answers

2


I got the solution

for /r %d in (*.jpg) do copy /Y "%d" "C:\Users\IRINEU\Desktop\a\b"

the parameter /r of for he searches the sub-sections

declared the variable d thus -> %d

(*.jpg) 

this parameter searches for all . jpg

  • +1 Perfect the solution, mark as accepted to guide future visitors

  • I can only do it in two days if you can copy and post it for me to accept

  • Accept your same in two days, you deserve to receive the points by posting, it would not be fair another do it.

0

Create a file. bat for this, and inserts the command, it will be somewhat artisanal, but only the part of creating the listing of subdirectories, for example:

move c:\diretorio1\*.* g:\ /y
move c:\diretorio2\subdiretorio1\*.* g:\ /y
move c:\diretorio2\subdiretorio2\*.* g:\ /y
move c:\diretori3\subdiretorio1\*.* g:\ /y

And then execute him.

  • If you use PHP for example on a local server, you can recur as well

  • 1

    this is not very feasible but I found a little bit better now for /r %d in (*.jpg) from copy /Y "%d" "C: Users IRINEU Desktop a b"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.