removing bytes from multiple files

  • Thread starter Thread starter cranberry girl
  • Start date Start date
C

cranberry girl

I have a large number of what ought to be .jpg files that have corrupt
headers.

I need to remove the first x bytes from all of them (luckily it's an
identical number from each!)

I suppose I could do each one individually but is there an easy to use
freeware app that'll let me do that on multiple files?

Thanks
 
cranberry girl said:
I have a large number of what ought to be .jpg files that have corrupt
headers.

I need to remove the first x bytes from all of them (luckily it's an
identical number from each!)

I suppose I could do each one individually but is there an easy to use
freeware app that'll let me do that on multiple files?

Thanks

You're not removing bytes from files; you're removing
characters from file names. This little batch file will remove
the first three characters from your .jpg files, provided that
the file names do not contain ampersands (&):

@echo off
dir /b *.jpg > c:\Files.txt
for /F "tokens=*" %%* in (c:\Files.txt) do call :Sub %%*
del c:\Files.txt
goto :eof

:Sub
set name=%*
echo ren "%name%" "%name:~3%"

Remove the word "echo" from the last line to activate the
batch file.
 
Erm, no - there's nothing wrong with the filenames.

I need to remove the first 164 bytes from the files themselves.
 
The freeware hex editor XVI32 is available at:

http://www.chmaas.handshake.de/

It has scripting capabilities and can be launched from a command line specifying the file to be
opened and the script to be executed. You can wrap that command line in a batch file and you should
be well on your way. Examples are in the included help file.
 
Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

Set ts = fso.OpenTextFile(Ag(0), 1, vbtrue)

A=ts.readall

B=Mid(A, 165)

ts.close

Set ts = fso.OpenTextFile(Ag(0), 2, vbtrue)

ts.write B

-------------------------------------
Put above in a new text document and rename it to something.vbs. It D E S T R O Y S the original file so backup before running it.

Drag and drop the file to be changed over the vbs icon.

Y O U N E E D T O T E S T. This line , B=Mid(A, 165), I think takes the 165th character (and to the end), but I can't count that high so you'll have to test it that it snips the exact amount you want (I suspect it will be out by one - but I can't count that high).

So TEST on a COPY of a file.

To do all jpgs in a directory assuming the vbs is named snip.vbs and is in c:\.

For %A in ("*.jpg") do c:\snip %A
 
Nice one!


Keith Miller said:
The freeware hex editor XVI32 is available at:

http://www.chmaas.handshake.de/

It has scripting capabilities and can be launched from a command line specifying the file to be
opened and the script to be executed. You can wrap that command line in a batch file and you should
be well on your way. Examples are in the included help file.

--
Good Luck,

Keith
Microsoft MVP [Windows XP Shell/User]


cranberry girl said:
I have a large number of what ought to be .jpg files that have corrupt
headers.

I need to remove the first x bytes from all of them (luckily it's an
identical number from each!)

I suppose I could do each one individually but is there an easy to use
freeware app that'll let me do that on multiple files?

Thanks
 
Thanks - I'll give that a go :)

Keith Miller said:
The freeware hex editor XVI32 is available at:

http://www.chmaas.handshake.de/

It has scripting capabilities and can be launched from a command line
specifying the file to be
opened and the script to be executed. You can wrap that command line in a
batch file and you should
be well on your way. Examples are in the included help file.

--
Good Luck,

Keith
Microsoft MVP [Windows XP Shell/User]


cranberry girl said:
I have a large number of what ought to be .jpg files that have corrupt
headers.

I need to remove the first x bytes from all of them (luckily it's an
identical number from each!)

I suppose I could do each one individually but is there an easy to use
freeware app that'll let me do that on multiple files?

Thanks
 
Fantastic - thanks :)

"David Candy" <.> wrote in message
Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

Set ts = fso.OpenTextFile(Ag(0), 1, vbtrue)

A=ts.readall

B=Mid(A, 165)

ts.close

Set ts = fso.OpenTextFile(Ag(0), 2, vbtrue)

ts.write B

-------------------------------------
Put above in a new text document and rename it to something.vbs. It D E S
T R O Y S the original file so backup before running it.

Drag and drop the file to be changed over the vbs icon.

Y O U N E E D T O T E S T. This line , B=Mid(A, 165), I think takes
the 165th character (and to the end), but I can't count that high so you'll
have to test it that it snips the exact amount you want (I suspect it will
be out by one - but I can't count that high).

So TEST on a COPY of a file.

To do all jpgs in a directory assuming the vbs is named snip.vbs and is in
c:\.

For %A in ("*.jpg") do c:\snip %A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Recovering lost JPEGs on hard drive 5
Transferring files to a HD Nook 5
Byte[] and File 6
Can't remove KB977165 with batch file 3
What is a Byte? 4
Baulk Renaming Files 2
Byte differences... 3
Ghost file 3

Back
Top