Computing.Net > Forums > Programming > Batch File Search and Paste

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 Search and Paste

Reply to Message Icon

Name: BrianSierakowski
Date: August 30, 2007 at 13:25:08 Pacific
OS: 2000
CPU/Ram: p3, 256 ram
Product: Proprietary recording mac
Comment:

Ok, here's probably a tricky one...

I have a drive that has data on it, which is organized into two file types, a .wav and a .ifo. The files are in folder schemes based on the channel, and the date, so the location of a file for today on channel one could be D:/001/08302007/filename.ifo.

What had happened is someone cut all the wavs off the drive, and put them all into 1 folder, by searching the drive for *.wav, then pasting all the results in one folder.

Now….. we need to put all the files back onto the drive for them to be restored, pairing the .wav back with the .ifo. They're named the same, for example one pair is ")TK!%XCD.ifo" and “)TK!%XCD.wav”.

The reason why this is tricky to do by hand is since we have about 30 channels, and 3 months of data, there are over 250,000 files in about 25,000 folders. So instead of taking the file name, searching the folder where all the wav’s got cut to (prelogbak), then cutting the wav into the folder 250,000, it would be nice to have a program that could do this for me.

What I would like to do is have a batch file that would go through and look at what .ifo files are in a folder, then go to the folder with the wav files "C:/prelogbak" and copy the matching .wav file into the folder with the .ifo.

So it would go into D:/001/08302007/ and see D:/001/08302007/filename1.ifo, then go search C:/prelogbak for filename1.wav. When it finds it, it pastes filename1.wav in the same folder with filename1.ifo. Then it goes on to all the other files and folders, etc.

If this cant be done, I'd settle for a batch file that could do a dir of the ifo files, then take of the extension so I could drop it into a search, so instead of having
File1.ifo
File2.ifo
File3.ifo

I’d rather have
File1, File2, File3.

Sorry for the tall order :D.

-Brian



Sponsored Link
Ads by Google

Response Number 1
Name: Shr0Om
Date: August 31, 2007 at 03:02:42 Pacific
Reply:

You dont have any backup you could restore??


0

Response Number 2
Name: Razor2.3
Date: August 31, 2007 at 03:27:20 Pacific
Reply:

It's untested, so take it for what it's worth:

FOR /R C:\ %a IN (*.ifo) DO MOVE "C:\prelogbak\%~Na.wav" "%~DPa"

If you're still having problems, tell me what error it's throwing. If I'm not around, look for Mechanix2Go. He's probably the best command line scripter here. Oh, that CANNOT be run from a batch file/command script as posted. It'll only work from the Command Prompt.


0

Response Number 3
Name: BrianSierakowski
Date: August 31, 2007 at 04:12:13 Pacific
Reply:

Seems to be working like a charm!

I'll keep updating with... updates :D.

If i could be so bold, could you break down the string a little bit so I can understand the components? That way if i have to modify it i dont have to bug you guys :).

Thanks!
-Brian


0

Response Number 4
Name: Razor2.3
Date: August 31, 2007 at 05:27:19 Pacific
Reply:

Well, you COULD research it yourself.
FOR /?
MOVE /?

But basically, it breaks down like this:
FOR /R C:\ %a IN (*.ifo) DO
Search for *.ifo files.

FOR /R C:\ %a IN (*.ifo) DO
Start searching in C:\, and do all subdirectories. (Basically, search the entire drive.)

MOVE "C:\prelogbak\%~Na.wav" "%~DPa"
Move the .WAV file in C:\prelogbak, which has the same base name as the .IFO file we found...

MOVE "C:\prelogbak\%~Na.wav" "%~DPa"
...to wherever that .IFO file is.


0

Response Number 5
Name: Mechanix2Go
Date: August 31, 2007 at 05:49:01 Pacific
Reply:

Razor2.3,

That's pretty slick, slick. Much cleaner than my approach. LOL

Brian,

As you tinker and learn, note that the path delimiter in DOS and windows is \ NOT /.



=====================================
If at first you don't succeed, you're about average.

M2



0

Related Posts

See More



Response Number 6
Name: Shr0Om
Date: August 31, 2007 at 06:25:28 Pacific
Reply:

Slick indeed.
Say, how does these lines work?
~Na.wav" "%~DPa"

(Where does Na and DPa come from? Also, how does %~xxx work?)


0

Response Number 7
Name: BrianSierakowski
Date: August 31, 2007 at 07:22:05 Pacific
Reply:

Research it for myself?!

What sort of crazy talk is that??!

Hahaha, thank you very much again, it's still running, but everything is looking fantastic :D.


0

Response Number 8
Name: Mechanix2Go
Date: August 31, 2007 at 07:23:01 Pacific
Reply:

shroom,

Look at for /?


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 9
Name: Shr0Om
Date: August 31, 2007 at 13:19:15 Pacific
Reply:

Mechanix2Go: Aah.. Expanding full path..
Thnx:)


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch File Search and Paste

Batch File search and delete file www.computing.net/answers/programming/batch-file-search-and-delete-file/16386.html

Batch file copy and Rename www.computing.net/answers/programming/batch-file-copy-and-rename/18689.html

Batch File Find and Replace www.computing.net/answers/programming/batch-file-find-and-replace/15766.html