Computing.Net > Forums > Disk Operating System > Batch file that dir's minus prefix

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file that dir's minus prefix

Reply to Message Icon

Name: goompa
Date: February 25, 2009 at 17:35:18 Pacific
OS: Windows xp
Subcategory: General
Comment:

Hi there. Here is my problem:
Folder A has a large number of mp3 files in it. It's constantly being added to by an automatic ftp download each night.
Folder B is a play out folder. it contains the same files which are manually copied and then renamed by FlashRename with a 1000_ incremental prefix.

What I would like to do is create a batch file that would compare each file from Folder A and Folder B. If the same file does not exist it copies the file from Folder A to Folder B.

This would be great. What would be even better would be if the batch could track the dates listed in the file names. In the case I'm working on the file names are "1040_sly_Mar0209.mp3 . 02 is the day, 09 is the year.

To start to compare file names I need to be able to ignore the prefix and first underscore.

I'm currently playing with dir /b. I was trying to see if I could list the mp3's without the prefixes.

Something like you use to display specific characters in the set command.

Anyways, pleace throw a dog a bone.
Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: paulsep
Date: February 25, 2009 at 18:43:27 Pacific
Reply:

Am I right?
Do you want to compare only the filenames or would you like to compare the file?

If you would like to compare the files, I wonder, if that is what you really want.

Assuming there are 100 files in folder A and 1000 files in folder B.
So you will compare 1 file with 1000 others.
That gives 100 x 1000 = 100000.

So lets assume each comparison takes 5 seconds.
It take 500000 seconds or 8333 minutes or 138,8 hours.

I think, you won't do that every night.
;-)

Please send a reply, if you solved the problem !!!


0

Response Number 2
Name: goompa
Date: February 25, 2009 at 19:06:13 Pacific
Reply:

Hi Paul, thanks for the reply.

for starters I need to look in Folder A then look in Folder B to see if there is a filename with the same name except it will have a 4 digit prefix.

Folder A
sly_Mar0209.mp3
sly_Mar0309.mp3
sly_Mar0409.mp3
sly_Mar0509.mp3
sly_Mar0609.mp3
sly_Mar0909.mp3
sly_Mar1009.mp3
sly_Mar1109.mp3

Folder B
1045_sly_Mar0209.mp3
1046_sly_Mar0309.mp3
1047_sly_Mar0409.mp3
1048_sly_Mar0509.mp3


As you can see there are 4 files in Folder A that are not in Folder B. These need to be copied over and have the incremental prefix attached to the file name in order.

Has this made it clearer?

Even if I can get part of this solved that would be great.

Thanks for your time.


0

Response Number 3
Name: paulsep
Date: February 25, 2009 at 20:31:54 Pacific
Reply:

From beginner back to you !!!

for /f "tokens=2* delims=_" %%i in ('dir /b "*.mp3"') do @echo "%%i_%%j"

This should give you an idea, on how you can manage it.

Please send a reply, if you solved the problem !!!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Batch file that dir's minus prefix

batch file that will delete folders www.computing.net/answers/dos/batch-file-that-will-delete-folders/14500.html

How do u make a batch file that runs whenever the computer boots up www.computing.net/answers/dos/how-do-u-make-a-batch-file-that-runs-whenever-the-computer-boots-up/3744.html

batch file that gives you a menu of files to load www.computing.net/answers/dos/batch-file-that-gives-you-a-menu-of-files-to-load/2971.html