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

Author Topic: Resolved: Moving all .mp3  (Read 6171 times)

0 Members and 1 Guest are viewing this topic.

Dark Blade

    Topic Starter
  • Forum Gaming Master


  • Adviser

    Thanked: 24
    • Yes
  • Experience: Experienced
  • OS: Windows XP
Resolved: Moving all .mp3
« on: May 25, 2007, 06:50:51 PM »
Well, using Command Prompt (or a batch file is needs be), how could I copy all .mp3 files in a certain directory (C:\Documents and Settings\Owner\My Documents) and all sub-directories to a certain folder (C:\Documents and Settings\Owner\My Music)?
« Last Edit: May 26, 2007, 10:15:42 PM by Dark Blade »

helper



    Intermediate
  • Thanked: 1
    Re: Moving all .mp3
    « Reply #1 on: May 25, 2007, 06:58:01 PM »
    move C:\Documents and Settings\Owner\My Documents\*.mp3 C:\Documents and Settings\Owner\My Music

    Dark Blade

      Topic Starter
    • Forum Gaming Master


    • Adviser

      Thanked: 24
      • Yes
    • Experience: Experienced
    • OS: Windows XP
    Re: Moving all .mp3
    « Reply #2 on: May 25, 2007, 07:05:49 PM »
    For that to work, I think you'd need to do this:

    copy "C:\Documents and Settings\Owner\My Documents\*.mp3" "C:\Documents and Settings\Owner\My Music"

    I already knew how to do that, but I don't know how to move everything in sub-directories, which is my problem.

    GuruGary



      Adviser
      Re: Moving all .mp3
      « Reply #3 on: May 25, 2007, 07:31:48 PM »
      To COPY with ALL SUBDIRECTORIES, I would use:
      Code: [Select]
      xcopy "C:\Documents and Settings\Owner\My Documents\*.mp3" "C:\Documents and Settings\Owner\My Music" /s /c
      There are additional switches you can use if there are hidden or system files or directories that contain MP3 files.

      Dark Blade

        Topic Starter
      • Forum Gaming Master


      • Adviser

        Thanked: 24
        • Yes
      • Experience: Experienced
      • OS: Windows XP
      Re: Moving all .mp3
      « Reply #4 on: May 25, 2007, 07:34:59 PM »
      Thanks for the help! I'll keep xcopy in mind.

      CBMatt

      • Mod & Malware Specialist


      • Prodigy

      • Sad and lonely...and loving every minute of it.
      • Thanked: 167
        • Yes
      • Experience: Experienced
      • OS: Windows 7
      Re: Moving all .mp3
      « Reply #5 on: May 26, 2007, 05:08:13 AM »
      I don't mean to hijack, but knowing only a select few commands right now, I'm a bit curious...what if in two different directories, there are two files with the same name?  Since they are being moved into the same folder...will one file override the other, will one automatically be renamed, or will they not get moved?  Or would there be an error?  Probably a silly question, but this really isn't my field.

      EDIT:  Just tried it out for myself and it simply moved all of the subdirectories containing MP3 files.  I thought the goal was to move just the files?
      Quote
      An undefined problem has an infinite number of solutions.
      由obert A. Humphrey

      Carbon Dudeoxide

      • Global Moderator

      • Mastermind
      • Thanked: 169
        • Yes
        • Yes
        • Yes
      • Certifications: List
      • Experience: Guru
      • OS: Mac OS
      Re: Moving all .mp3
      « Reply #6 on: May 26, 2007, 05:16:15 AM »
      I think if both files are named hello.mp3 and they are moved to one file, i think one would be hello.mp3 and the other one would be hello(1).mp3 or something like that.

      EDIT: no it overwrites it.

      CBMatt

      • Mod & Malware Specialist


      • Prodigy

      • Sad and lonely...and loving every minute of it.
      • Thanked: 167
        • Yes
      • Experience: Experienced
      • OS: Windows 7
      Re: Moving all .mp3
      « Reply #7 on: May 26, 2007, 05:18:20 AM »
      That's what I was thinking, but testing it for myself didn't answer my question (see my above edit).
      Quote
      An undefined problem has an infinite number of solutions.
      由obert A. Humphrey

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Moving all .mp3
      « Reply #8 on: May 26, 2007, 05:35:47 AM »
      XCOPY always seems like a crap shoot to me. I'm never sure which switches will produce the results I'm looking for.

      Sometimes it's easier to plod along  one file at a time.

      Code: [Select]
      @echo off
      for /f "tokens=* delims=" %%i in ('dir "C:\Documents and Settings\Owner\My Document\*.mp3" /s') do (
      copy "%%i" "C:\Documents and Settings\Owner\My Music"
      )

      I'm fairly certain the user will be prompted to overwrite duplicate file names in the target direcory.

       8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      CBMatt

      • Mod & Malware Specialist


      • Prodigy

      • Sad and lonely...and loving every minute of it.
      • Thanked: 167
        • Yes
      • Experience: Experienced
      • OS: Windows 7
      Re: Moving all .mp3
      « Reply #9 on: May 26, 2007, 07:21:50 AM »
      Not too sure what I might've done wrong, but that did absolutely nothing for me...
      Quote
      An undefined problem has an infinite number of solutions.
      由obert A. Humphrey

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Moving all .mp3
      « Reply #10 on: May 26, 2007, 07:40:18 AM »
      It seemed reasonable the OP user name is Owner ;D Perhaps this will make it more generic.

      Code: [Select]
      @echo off
      for /f "tokens=* delims=" %%i in ('dir "C:\Documents and Settings\%Username%\My Document\*.mp3" /s') do (
      copy "%%i" "C:\Documents and Settings\%Username%\My Music"
      )

      Quote
      Not too sure what I might've done wrong, but that did absolutely nothing for me...

      No message at all? Nothing on the console? Usually the command shell sends some sort of an error message, no matter how cryptic it maybe.

       8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      CBMatt

      • Mod & Malware Specialist


      • Prodigy

      • Sad and lonely...and loving every minute of it.
      • Thanked: 167
        • Yes
      • Experience: Experienced
      • OS: Windows 7
      Re: Moving all .mp3
      « Reply #11 on: May 26, 2007, 08:00:01 AM »
      Setting it as %Username% actually did less, I think.  Heh.

      In my last post, I shouldn't have said it did nothing.  I should've said it made no changes.  The console appeared and there was some text, but it closed too quickly for me to be able to read it.  It looked like it was a list of everything in the directory, though.

      Keep in mind that I changed Owner to Owner.Murgatroyd7, which is my username.  When I change that to %Username%, the console is blank during the split-second it opens.

      The only changes I have made are to the directories, and I'm certain I am using the correct paths.
      Quote
      An undefined problem has an infinite number of solutions.
      由obert A. Humphrey

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Moving all .mp3
      « Reply #12 on: May 26, 2007, 08:49:24 AM »
      Try running from the command prompt. As you said using the run box or windows explorer, closes the windows too fast to read. If you could post your file (including the directory changes you made) it would be easier to debug.

      Not for nothing, but what happened to the OP?

       8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      CBMatt

      • Mod & Malware Specialist


      • Prodigy

      • Sad and lonely...and loving every minute of it.
      • Thanked: 167
        • Yes
      • Experience: Experienced
      • OS: Windows 7
      Re: Moving all .mp3
      « Reply #13 on: May 26, 2007, 09:38:24 AM »
      I went ahead and just added a pause at the end (don't know why I didn't think of that earlier) to keep the window from closing.

      This is the exact error...
      Quote
      The system cannot find the file specified.
      The system cannot find the file specified.
        Directory of C:\Documents and Settings\Owner.Murgatroyd7\Desktop\test\Angelo Spencer
      The filename, directory name, or volume label syntax is incorrect.
                  0 file(s) copied.
      The system cannot find the file specified.
      The system cannot find the file specified.
      The system cannot find the file specified.
      "         Total Files Listed:" is not a recognized device.
               Total Files Listed:
      The filename, directory name, or volume label syntax is incorrect.
                  0 file(s) copied.
      The system cannot find the file specified.
      The system cannot find the file specified.
      Desktop\test is a folder with various files.  "Angelo Spencer" is the subdirectory which houses the MP3's.

      Here is the exact code I'm using...

      Code: [Select]
      @echo off
      for /f "tokens=* delims=" %%i in ('dir "C:\Documents and Settings\Owner.Murgatroyd7\Desktop\test\*.mp3" /s') do (
      copy "%%i" "C:\Documents and Settings\Owner.Murgatroyd7\Desktop\curious\"
      )
      Desktop\curious is where I'm trying to move the files to.


      I know for sure that the directory paths are correct.  If they weren't, the below code wouldn't work...
      Code: [Select]
      xcopy "C:\Documents and Settings\Owner.Murgatroyd7\Desktop\test\*.mp3" "C:\Documents and Settings\Owner.Murgatroyd7\Desktop\curious" /s /c
      Quote
      An undefined problem has an infinite number of solutions.
      由obert A. Humphrey

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Moving all .mp3
      « Reply #14 on: May 26, 2007, 10:04:11 AM »
      Apologies for the oversight:

      Code: [Select]
      @echo off
      for /f "tokens=* delims=" %%i in ('dir "C:\Documents and Settings\Owner.Murgatroyd7\Desktop\test\*.mp3" /b /s') do (
      copy "%%i" "C:\Documents and Settings\Owner.Murgatroyd7\Desktop\curious\"
      )

       8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      CBMatt

      • Mod & Malware Specialist


      • Prodigy

      • Sad and lonely...and loving every minute of it.
      • Thanked: 167
        • Yes
      • Experience: Experienced
      • OS: Windows 7
      Re: Moving all .mp3
      « Reply #15 on: May 26, 2007, 10:20:31 AM »
      There we go, that did it!  This will surely come in handy.  Thanks!

      One little thing, however...In the test folder, I have two subdirectories: happy and new year.  Each of those contains a text file try.txt (same filename, but different content).  When I use this batch for .txt files, it only copies the new year file and not the happy one.  So, that must mean that one is overwriting the other.  What can be done about this?



      (I've completely hijacked your thread, Dark Blade, and I'm sorry, but I think the information here will benefit you.)
      Quote
      An undefined problem has an infinite number of solutions.
      由obert A. Humphrey

      GuruGary



        Adviser
        Re: Moving all .mp3
        « Reply #16 on: May 26, 2007, 11:54:16 AM »
        For XCOPY, you can user the /D switch to tell it to only overwrite an existing file if the file to be copied is newer.  XCOPY will also keep the directory tree like it is in the source.  If you want to merge all files into a single directory, then use code like Sidewinders.

        CBMatt

        • Mod & Malware Specialist


        • Prodigy

        • Sad and lonely...and loving every minute of it.
        • Thanked: 167
          • Yes
        • Experience: Experienced
        • OS: Windows 7
        Re: Moving all .mp3
        « Reply #17 on: May 26, 2007, 01:16:55 PM »
        But what I'm wondering is...when using Sidewinder's code, how can I prevent overwriting?  I'm not too worried about it with xcopy, but it's a problem with his code.

        If I wanted to copy my entire music collection into one directory, I'd lose hundreds of songs.  I've got at least fifteen California.mp3 files, and they're all different songs.  How would I set up the batch file to prompt me to overwrite or not?

        Better yet, how could it be set up to automatically rename like-named files (California(1).mp3, California(2).mp3, etc.)?
        Quote
        An undefined problem has an infinite number of solutions.
        由obert A. Humphrey

        WillyW



          Specialist
        • Thanked: 29
        • Experience: Experienced
        • OS: Windows XP
        Re: Moving all .mp3
        « Reply #18 on: May 26, 2007, 02:10:44 PM »
        But what I'm wondering is...when using Sidewinder's code, how can I prevent overwriting?  I'm not too worried about it with xcopy, but it's a problem with his code.
        ...

        Try experimenting with the -y switch.

        Check out:
        http://www.vfrazee.com/ms-dos/6.22/help/xcopy.htm
        and
        http://www.vfrazee.com/ms-dos/6.22/help/copy.htm

        Note the explanation:
         " (Previous versions of MS-DOS would simply replace the
            existing file.) If the COPY command is part of a batch file, COPY will
            behave as in previous versions. "


        Bear in mind that this info was written about MS-DOS.   

        .



        GuruGary



          Adviser
          Re: Moving all .mp3
          « Reply #19 on: May 26, 2007, 05:01:05 PM »
          Better yet, how could it be set up to automatically rename like-named files (California(1).mp3, California(2).mp3, etc.)?
          How about this:
          Code: [Select]
          @echo off
          setlocal
          set Source=C:\Documents and Settings\Owner.Murgatroyd7\Desktop\test
          set Dest=C:\Documents and Settings\Owner.Murgatroyd7\Desktop\curious

          for /f "delims=" %%a in ('dir "%Source%\*.mp3" /b /s') do (
             if exist "%Dest%\%%~na%%~xa" (
                call :IncrementFile "%%a"
                ) else copy "%%a" "%Dest%"
             )
          goto :EOF

          :IncrementFile
          for /l %%b in (1,1,99) do (
             if not exist "%Dest%\%~n1(%%b)%~x1" (
                copy %1 "%Dest%\%~n1(%%b)%~x1"
                exit /b
                )
             )
          That should rename up to 99 copies of the same file.  It takes all the .MP3 files from SOURCE and all of it's subdirectories and puts them all in a flat directory of DEST.

          Is that what you are looking for?

          CBMatt

          • Mod & Malware Specialist


          • Prodigy

          • Sad and lonely...and loving every minute of it.
          • Thanked: 167
            • Yes
          • Experience: Experienced
          • OS: Windows 7
          Re: Moving all .mp3
          « Reply #20 on: May 26, 2007, 10:12:28 PM »
          That's perfect, Gary.  Thanks a lot for that!

          And thanks for the links, Willy.  I'm going to read up on those when I have some free time tonight.



          Dark Blade...I believe I'm done with rudely hijacking your thread.  I hope my questions here benefit you as much as they benefit myself.
          Quote
          An undefined problem has an infinite number of solutions.
          由obert A. Humphrey

          Dark Blade

            Topic Starter
          • Forum Gaming Master


          • Adviser

            Thanked: 24
            • Yes
          • Experience: Experienced
          • OS: Windows XP
          Re: Moving all .mp3
          « Reply #21 on: May 26, 2007, 10:15:19 PM »
          Well, at least you waited unitl my question was answered before hijacking, so I guess it was alright.

          This thread (and your hijacking of it) has actually helped me learn a few things about the for command. It's not as hard as I thought!

          Code: [Select]
          if not exist "%Dest%\%~n1(%%b)%~x1" (
                copy %1 "%Dest%\%~n1(%%b)%~x1"

          But not smart enough to have ANY idea what that means.


          Anyway, I'll rename this post Resolved, to get into the spirit of things.
          « Last Edit: May 27, 2007, 01:37:30 AM by Dark Blade »

          WillyW



            Specialist
          • Thanked: 29
          • Experience: Experienced
          • OS: Windows XP
          Re: Moving all .mp3
          « Reply #22 on: May 27, 2007, 11:17:20 AM »


          And thanks for the links, Willy.

          You're welcome. 

          Quote
            I'm going to read up on those when I have some free time tonight.


          Instead, you might want to bookmark this:
          http://www.vfrazee.com/ms-dos/6.22/help/

          That's pretty much what we used to get when we typed      help      at the command line,  back when Billy was only worth a few hundred million bucks.    :)

          Everything on that page that is enclosed in the green   <  >    symbols is a link. 


          .