Saturday, August 11, 2018

how to concatenate files within each subdirectory using windows command prompt

I'm a newbie, a grad student, and frustrated!! I have tons of directories containing subdirectories and each subdirectory contains a bunch of .irf files (these are a DVR-type file).



I am trying to use the command prompt to get each subdirectory to contain a concatenated .irf file for the .irf's in that subdirectory. And ideally the new file would have the name of the subdirectory.



I can concatenate them no problem, going into each subfolder one by one:




copy /b *.irf concat.irf


To get this to work for each subdirectory I've been trying to use the for command and I put the copy command into a batch file (copyIRF.bat)



for /d /r %i in (*.*) do call copyIRF.bat %i )


This puts a concatenated file called concat.irf into the parent directory that is the combined files from subdirectory #1.




But then when it concats the files in the second directory it appends those to the same file concat.irf in the parent folder instead of putting the resulting files into their respective subdirectories.



What I want is:



Directory
Subdir1
*.irf
*.irf
*.irf...etc.
Subdir1concat.irf

Subdir2
*.irf
*.irf
*.irf ...etc..
Subdir2concat.irf


I really really appreciate any help!!



(I use Win 7 64bit pro)

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...