Home / Microsoft / Microsoft DOS / Replace integrity of many files with one
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: Replace integrity of many files with one  (Read 522 times)
shish
Topic Starter
Greenhorn



Posts: 8


« on: July 21, 2009, 09:15:36 AM »

Good morning, I have a very daunting task before me that I really could use some help with. I have 652 files named in an increasing sequence “startofthefilename000_000” the 000_000 change. My problem is I need to take one file and replace the integrity of the 652; while keeping their naming convention of course.

I have a few years programming experience, and networking but its been years since I have touched dos. I have windows XP, is there anyway I could use Replace with wild cards or some other command from the windows Command Prompt to do this? Or could a batch file be able easily accomplish this?

I would greatly appreciate any help,
IP logged
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #1 on: July 21, 2009, 09:48:03 AM »

Could you please explain what you mean by the "integrity of the 652"? In fact, could you please explain much more clearly what it is that you want to do?

IP logged


Proud to be European
shish
Topic Starter
Greenhorn



Posts: 8


« Reply #2 on: July 21, 2009, 10:03:17 AM »

I have 6  folders, with a total of 652 files. To simplify things I'll just deal with one.

The folder is called small and it has 310 files in it are "small00_00" followed by "small00_01" up through "small00_09" then next file is "small01_00" this goes up to "small29_09". They are different color textures, I need to bland things out by replacing each of them with the same color. So I meant integrity as the files contents being changed.
IP logged
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #3 on: July 21, 2009, 10:12:27 AM »

Thank you. Please confirm that I understand properly.

You have a number of folders. Each folder contains a number of files. They are different. You want to change them so all the files have the same contents as each other, but preserving their former filenames?

IP logged


Proud to be European
shish
Topic Starter
Greenhorn



Posts: 8


« Reply #4 on: July 21, 2009, 10:17:29 AM »

Correct, you hit the nail right on the head.
IP logged
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #5 on: July 21, 2009, 10:35:12 AM »

So... you want to do this, I think?

For each file in a folder:

delete (Query: or rename?) the file?
create a new file with the same name
place in that file some standard contents (Query: unique to that folder, or the same for all 652 files?) 

There are a number of tools that can be used to do this. A batch file, or a Visual Basic Script (VBS), or another tool such as awk or perl or others still. I know how to do this sort of thing in a batch file, but other people can probably suggest much more elegant solutions using the other tools I have mentioned. Please, therefore, state your preference.

IP logged


Proud to be European
shish
Topic Starter
Greenhorn



Posts: 8


« Reply #6 on: July 21, 2009, 10:40:21 AM »

Great to hear, I dislike VB, a batch file would work well.

(Query: unique to that folder, or the same for all 652 files?) 

Unique to that folder.
IP logged
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #7 on: July 21, 2009, 10:47:27 AM »

So you might have a folder called small and a file called small_new (in that folder?) and you wish to make all the other files identical to that?

IP logged


Proud to be European
shish
Topic Starter
Greenhorn



Posts: 8


« Reply #8 on: July 21, 2009, 10:49:50 AM »

That would be perfect!
IP logged
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #9 on: July 21, 2009, 10:55:09 AM »

You did not answer whether you wish to destroy or preserve the previously existing files.
IP logged


Proud to be European
shish
Topic Starter
Greenhorn



Posts: 8


« Reply #10 on: July 21, 2009, 10:57:10 AM »

I apologize, I would wish that they are destroyed.
IP logged
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #11 on: July 21, 2009, 11:48:59 AM »

Suppose you call this file MakeAllSameAs.bat and

place it in a folder containing the files to be altered and the file to be copied to each

open a command window in that folder and type its name followed by the name of the file to be copied e.g.

MakeAllSameAs "small_new"

Code: [Select]
@echo off
set repfile=%~1
echo Replacement file: %repfile%
for /f "delims=" %%F in (' dir /b ^| find /v "%repfile%" ^| find /v "MakeAllSameAs.bat" ' ) do (
Echo Replacing %%F
del "%%F"
copy "%repfile%" "%%F"
)


« Last Edit: July 21, 2009, 12:35:55 PM by Salmon Trout » IP logged


Proud to be European
shish
Topic Starter
Greenhorn



Posts: 8


« Reply #12 on: July 21, 2009, 12:08:30 PM »

It works, thank you very much. This is very exciting!!!
IP logged
gh0std0g74
Apprentice



Thanked: 37
Posts: 590


« Reply #13 on: July 21, 2009, 05:46:38 PM »

Suppose you call this file MakeAllSameAs.bat and

place it in a folder containing the files to be altered and the file to be copied to each

open a command window in that folder and type its name followed by the name of the file to be copied e.g.

MakeAllSameAs "small_new"

Code: [Select]
@echo off
set repfile=%~1
echo Replacement file: %repfile%
for /f "delims=" %%F in (' dir /b ^| find /v "%repfile%" ^| find /v "MakeAllSameAs.bat" ' ) do (
Echo Replacing %%F
del "%%F"
copy "%repfile%" "%%F"
)



you can use findstr, then you don't need to pipe to find 2 times
Code: [Select]
for ....  ( dir /b ..  | findstr /v /c:string1 /c:string2 ) do (... )
IP logged

Pages: [1] - (Top) Print 
Home / Microsoft / Microsoft DOS / Replace integrity of many files with one « 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.125 seconds with 20 queries.