0

I have recently put plex onto my nas running freenas. I have setup a music library to my main folder for music and plex has found my mp3 and flac files which i didn't want it to do. Is there a way i can move all mp3 files to another location with one command?

I would like this to happen; Move mp3 files from /Music/ to /mp3Music/ for every single artist which i have a folder for.

I am using windows and can use CMD for commands or batch files.

UPDATE: I have the following command for /R %i in (*.MP3) do move "%i" "Y:/" it copied the files into the directory but didn't put them into the folders so it looks like the original.

Nooble
  • 3
  • 3
  • You are probably looking for the `for` loop (type `for /?` in a new command prompt window and read the help very carefully)... – aschipfl Jul 12 '16 at 15:10
  • i don't know much about commands at all could you give me a command that i could test out. I can change the paths if you could just do the command. – Nooble Jul 12 '16 at 15:36
  • 1
    Start with the help information that aschipfl told you about. Then try writing something. Maybe make a test directory with just a few fake files in it to test it out. If it doesn't work, edit your question with what you tried and someone can help you fix it. – yellowantphil Jul 12 '16 at 16:06
  • I have tried this `for /R %i in (*.MP3) do move "%i" "Y:/"` and it copied the files but didn't put them into the folders they were in before. I looked through the help and i couldn't find anything which i thought would help me. – Nooble Jul 12 '16 at 16:25
  • Why do you not move the files with Windows Explorer as it looks like you need to do this only once? – Mofi Jul 12 '16 at 16:29
  • I have 434 folders that i would have to go into and manually move every mp3 files to the correct location in another folder. I figured it would be easier to use a command. – Nooble Jul 12 '16 at 16:31
  • In your attempt you are using `/` as path separator (`Y:/`), but you should always use the backspash in Windows/batch... – aschipfl Jul 12 '16 at 21:42

2 Answers2

1

Within a command prompt window run the following command line:

for /R %I in (*.mp3) do md "Y:%~pI" 2>nul & move "%I" "Y:%~pnxI"

Or create a batch file with following lines and execute it:

@echo off
for /R %%I in (*.mp3) do (
    md "Y:%%~pI" 2>nul
    move "%%I" "Y:%%~pnxI"
)

For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.

  • echo /?
  • for /?
  • md /?
  • move /?

And for an explanation of operator & read answer on Single line with multiple commands using Windows batch file.

2>nul used to redirect error messages output by command md to handle STDERR to device NUL to suppress them is explained in the Microsoft article Using command redirection operators.

Community
  • 1
  • 1
Mofi
  • 46,139
  • 17
  • 80
  • 143
0

Why don't you just use

copy *.mp3 y:
del *.mp3

I think that is much easier than doing this in a for loop

Or just use

move *.mp3 y:
Roman Gräf
  • 239
  • 2
  • 8
  • The goal was to move all MP3 files from entire directory tree of current directory with the directory structure to drive Y: and not just moving all MP3 files in current directory on current drive to current directory on drive Y: as your commands do. – Mofi Jul 13 '16 at 05:17