Home / Microsoft / Microsoft DOS / Resolved: Moving all .mp3
0 Members and 3 Guests are viewing this topic. « previous next »
Pages: 1 [2]  All - (Bottom) Print
Author Topic: Resolved: Moving all .mp3  (Read 1602 times)
CBMatt
Mod & Malware Specialist
Prodigy



Thanked: 160
Posts: 6,033

Experience: Experienced
OS: Windows 7


Sad and lonely...and loving every minute of it.

1
« 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.)
IP logged

Quote
An undefined problem has an infinite number of solutions.
—Robert A. Humphrey

Actually, the name's Chris...
GuruGary
Adviser



Posts: 771




« 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.
IP logged
CBMatt
Mod & Malware Specialist
Prodigy



Thanked: 160
Posts: 6,033

Experience: Experienced
OS: Windows 7


Sad and lonely...and loving every minute of it.

1
« 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.)?
IP logged

Quote
An undefined problem has an infinite number of solutions.
—Robert A. Humphrey

Actually, the name's Chris...
WillyW
Mentor



Thanked: 27
Posts: 1,823

Experience: Experienced
OS: Windows XP



« 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.   

IP logged

.


GuruGary
Adviser



Posts: 771




« 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?
IP logged
CBMatt
Mod & Malware Specialist
Prodigy



Thanked: 160
Posts: 6,033

Experience: Experienced
OS: Windows 7


Sad and lonely...and loving every minute of it.

1
« 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.
IP logged

Quote
An undefined problem has an infinite number of solutions.
—Robert A. Humphrey

Actually, the name's Chris...
Dark Blade
Topic Starter
Forum Gaming Master
Adviser



Thanked: 24
Posts: 724

Experience: Experienced
OS: Windows XP

1
« 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 » IP logged

WillyW
Mentor



Thanked: 27
Posts: 1,823

Experience: Experienced
OS: Windows XP



« 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. 


IP logged

.


Pages: 1 [2]  All - (Top) Print 
Home / Microsoft / Microsoft DOS / Resolved: Moving all .mp3 « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.111 seconds with 19 queries.