Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Moving all files from a tree to root  (Read 2083 times)

0 Members and 1 Guest are viewing this topic.

winniethepujols

  • Guest
Moving all files from a tree to root
« on: December 28, 2007, 11:17:21 AM »
Basically, I'm looking for a way (through DOs, perhaps?) to move all files in subfolders to the root directory. Let me explain this by showing my setup:


Parent : Music (Root)

Level 1 Sub-Directory: Green Day
Level 2 Sub-Directory: Dookie
DO - Song 1.mp3
DO - Song 2.mp3
DO - Song 3.mp3

Level 2 Sub-Directory: American Idiot
AI - Song 4.mp3
AI - Song 5.mp3
AI - Song 3.mp3



Level 1 Sub-Directory: Blink 182
Level 2 Sub-Directory: Enema of the State
ES - Song 1.mp3
ES - Song 2.mp3
ES - Song 3.mp3

Level 2 Sub-Directory: Blink 182 - Greatest Hits
BGH - Song 4.mp3
BGH - Song 5.mp3
BGH - Song 3.mp3


What I want to do is move all of the MP3 files to the "Music" folder; in other words, I want to move all files in subdirectories up to a desired parent folder.


Anyone know of a way I can do this? I searched for utilities online but it's kind of a difficult thing to search for. I was also thinking there is possibly a way to do this through DOS.

Moving manually is not practical -- there are hundreds of folders.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Moving all files from a tree to root
« Reply #1 on: December 28, 2007, 12:17:43 PM »
This may work for you:

Code: [Select]
@echo off
for /f "tokens=* delims=" %%x in ('dir /s /b \music\*.mp3') do (
move "%%x" \music
)

I guessed that those prefixes (DO, AI, ES, and BGH) were part of the song name otherwise you'll have problems with duplicate song titles.

Good luck. 8)


The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

winniethepujols

  • Guest
Re: Moving all files from a tree to root
« Reply #2 on: December 28, 2007, 01:45:22 PM »
It worked, thanks a million!