Move Foldercontent in parent folder

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
games1024
Posts: 1
Joined: 22 Jan 2010 12:25

Move Foldercontent in parent folder

#1 Post by games1024 » 22 Jan 2010 12:38

Hey guys, I have the following problem:
I need to put audio files (mp3s) from the subfolder in current.
Because I sync my psp with wmp and he automatically puts files in the folders like that \music\%interpret%\%album%\.
PSP can read music files with only one subfolder (\music\...\).
So I need to have a script putting foldercontent in the music folder without any subfolders.
I was thinking about a script like that:

Code: Select all

xcopy \*(//interpret)\*(//album)\*(//trackname).mp3 \(//folder of the script)*.mp3

But I dont know the syntax of "random folder".

Please help!!

--gameaIOZ4--

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Move Foldercontent in parent folder

#2 Post by aGerman » 22 Jan 2010 18:23

You can't use wildcards. But using DIR /S into a FOR /F loop will help surely. Figure out.

Code: Select all

@echo off
for /f "delims=" %%a in ('dir /a-d /b /s *.mp3') do copy "%%a" "%%~nxa"

You have to create the batch in "music".
But note, ampersands in file names or folder names will cause a faulty execution.

Post Reply