1

My question is very similar to this similar question on Linux.

I have received a catalog of images from Google Drive in multi-tiered (3 levels deep) sub directories that I need to upload to WordPress.

I thought it would be best to copy all images into 1 folder, making it easy to upload.

How do I move all images into 1 folder using a CMD command? (I'm on Windows 10)

Steve
  • 2,741
  • 17
  • 66
  • 117
  • Yes, thanks @PimpJuiceIT, but would prefer to copy files to a different directory - is that possible? – Steve Jul 24 '19 at 07:30
  • Yeah, prefer the full code please @PimpJuiceIT, thank you. – Steve Jul 24 '19 at 11:34
  • I've copied the code, altered the directory parameters, removed echo off, and I see the process completing okay inside the CMD window, but no files end up in the destination folder. [This is my version](https://pastebin.com/jGJDtTvC). – Steve Jul 25 '19 at 08:00
  • Sure. [Here's a sample of the output](https://pastebin.com/ZTLgYGFx). – Steve Jul 26 '19 at 04:13
  • Also, the script ended up deleting the files from the source directory. I don't want it to do this. – Steve Jul 26 '19 at 10:01
  • Hi @PimpJuiceIT, the other answer worked for me. I appreciate your help. – Steve Jul 30 '19 at 02:04
  • Hi @Steve - My apologies sir, I totally spaced this one. There was a major server issue for one of the companies I support and I was spending a lot of my extra time after my regular job troubleshooting and getting that resolved within the last few days. I totally spaced this or I would've taken another stab at it for you. I'm glad you got a working solution regardless for your need. I usually always try PowerShell solutions over batch myself now days as the logic is less complex and the features are way more robust. Glad you are all set and found what you needed for your task here +1 and some. – Vomit IT - Chunky Mess Style Jul 30 '19 at 02:33

1 Answers1

1

PowerShell

Get-ChildItem *.jpg -recurse | move-item -Destination 'C:\NewFolder'

PreCreate your destinaton folder or the command will fail.

Keith Miller
  • 8,704
  • 1
  • 15
  • 28
  • Looks good Keith, thank you, but not all files were copied. The first source directory I opened had JPGs that weren't in the destination folder. – Steve Jul 24 '19 at 07:31
  • And that's the directory you execuated the command from? – Keith Miller Jul 24 '19 at 14:01
  • Yes Keith, it is. – Steve Jul 25 '19 at 08:01
  • Hard to guess without seeing examples. Are they listed when you try `gci *.jpg`? – Keith Miller Jul 25 '19 at 13:51
  • I ran the command again, and let it run for much longer. I think last time, I forgot about the running process, and shut the laptop lid, ending the process too soon. The 2nd time the process completed properly. Thanks. – Steve Jul 30 '19 at 02:03