Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default File Extensions

Greetings !

OK, so my add-on hard drive is a tad screwed up - somehow my "My Pictures"
Folder has been converted into a file.

CHKDSK has been so kind(?) as to "recover" these "lost files", and name them
as FILE0001.CHK, etc. in folders called FOUND.000 etc.

As I understand it, some of those files are plain text files, so I could
simply rename those with the extension .txt

Well, that's not to difficult... ish !

I intend to get VBA to load up the first 64(?) characters of every file, and
compare these with those from the picture files I have back up, I can
eliminate those, leaving to be recovered only those files that I have omitted
to back up.

I have over fifty thousand .CHK file, in seven FOUND folders :(
That number will fit on one Excel WorkSheet.

If VBA checks that the first 64(?) characters are all between CHAR(32) and
CHAR(127), then (if they are), VBA can rename them with the .txt extension.

Now, using the incomparable and essential
-------------------------------------------------
LIST Version 6.4a 9/21/88
(c) Copyright Vernon D. Buerg 1983-88
139 White Oak Circle, Petaluma CA 94952
For personal use only. May not be sold.
-------------------------------------------------
it seems to me that
all .ZIP files seem to start with Hex(504B03) i.e. "PK"
all .PDF files seem to start with Hex(25504446) i.e. "%PDF"
all BitMap files (.BMP) seem to start with "BM"
all .TIF files seem to start with Hex(49492A) i.e. II*


So if SKS could
a) confirm that my logic is sound; and
b) advise me on how many characters I need to test; and
c) provide the information that is contained within
each file that identifies its type,

then I can rename the files with
the correct extensions and look at the contents !

Pretty please?

Or any other ideas - perhaps there is already
software "out there" that I could use ?

Others MUST have had this challenge before !

The Symantec help line couldn't (or wouldn't) advise.



Regards

Robin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default File Extensions

Before you do this, you may want to try a few renames manually. Open the file
(in notepad?) and see what the first few characters are.

Then rename that file accordingly.

Then try to open it in the appropriate application.

My bet (from looking at .chk's in the past) is that not many of them will be
opened.

I would put a few of those *.chk files in their own dedicated folder. It'll be
easier to clean up the bad .bmp files if they're segregated from the real .bmp
files.

Then try something like:

Option Explicit
Sub LookAtFiles()

Dim myFileNames As Variant
Dim fCtr As Long

myFileNames = Application.GetOpenFilename _
(FileFilter:="CheckDisk Files, *.chk", _
MultiSelect:=True)

If IsArray(myFileNames) Then
For fCtr = LBound(myFileNames) To UBound(myFileNames)
Call LookAtAndRename(CStr(myFileNames(fCtr)))
Next fCtr
End If

MsgBox "done"

End Sub

Sub LookAtAndRename(myFileName As String)

'all .ZIP files seem to start with Hex(504B03) i.e. "PK"
'all .PDF files seem to start with Hex(25504446) i.e. "%PDF"
'all BitMap files (.BMP) seem to start with "BM"
'all .TIF files seem to start with Hex(49492A) i.e. II*

Dim fNum As Long
Dim Buffer As String * 64
Dim NewFileName As String
Dim myExt As String

NewFileName = Left(myFileName, Len(myFileName) - 4)

fNum = FreeFile
Open myFileName For Binary As #fNum
Buffer = Space(64)
Get fNum, , Buffer
Close fNum

Buffer = LCase(Buffer)

myExt = ""
If Buffer Like "bm*" Then
myExt = "bmp"
ElseIf Buffer Like "pk*" Then
myExt = "zip"
ElseIf Buffer Like "%pdf*" Then
myExt = "pdf"
ElseIf Buffer Like "ii*" Then
myExt = "tif"
End If

If myExt = "" Then
'do nothing
Else
Name myFileName As NewFileName & "." & myExt
End If

End Sub

Run the first procedure and select as many as you want (ctrl-a to grab them all)
or click and ctrl-click to select a few less.

(don't get your hopes up!)

Robin Clay wrote:

Greetings !

OK, so my add-on hard drive is a tad screwed up - somehow my "My Pictures"
Folder has been converted into a file.

CHKDSK has been so kind(?) as to "recover" these "lost files", and name them
as FILE0001.CHK, etc. in folders called FOUND.000 etc.

As I understand it, some of those files are plain text files, so I could
simply rename those with the extension .txt

Well, that's not to difficult... ish !

I intend to get VBA to load up the first 64(?) characters of every file, and
compare these with those from the picture files I have back up, I can
eliminate those, leaving to be recovered only those files that I have omitted
to back up.

I have over fifty thousand .CHK file, in seven FOUND folders :(
That number will fit on one Excel WorkSheet.

If VBA checks that the first 64(?) characters are all between CHAR(32) and
CHAR(127), then (if they are), VBA can rename them with the .txt extension.

Now, using the incomparable and essential
-------------------------------------------------
LIST Version 6.4a 9/21/88
(c) Copyright Vernon D. Buerg 1983-88
139 White Oak Circle, Petaluma CA 94952
For personal use only. May not be sold.
-------------------------------------------------
it seems to me that
all .ZIP files seem to start with Hex(504B03) i.e. "PK"
all .PDF files seem to start with Hex(25504446) i.e. "%PDF"
all BitMap files (.BMP) seem to start with "BM"
all .TIF files seem to start with Hex(49492A) i.e. II*

So if SKS could
a) confirm that my logic is sound; and
b) advise me on how many characters I need to test; and
c) provide the information that is contained within
each file that identifies its type,

then I can rename the files with
the correct extensions and look at the contents !

Pretty please?

Or any other ideas - perhaps there is already
software "out there" that I could use ?

Others MUST have had this challenge before !

The Symantec help line couldn't (or wouldn't) advise.


Regards

Robin


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default File Extensions

iya, Dave !

Long time no....

Thank you for responding,
and offering your wisdom once more!

I have saved your message
and shall give it a go tomorrow.

I have actually tried renaming
with .BMP a file that seemed
as though it was one such, but
when I double clicked on it, the
process hung, and I had to use
Taskmanager to kill it.


Regards

Robin

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
don't want see file name with extensions. Rao Ratan Singh Excel Discussion (Misc queries) 7 March 14th 09 04:39 PM
File extensions colleen Excel Discussion (Misc queries) 3 September 16th 08 11:18 PM
File extensions Mex Excel Discussion (Misc queries) 5 August 4th 08 08:05 PM
file extensions dottiea Excel Discussion (Misc queries) 1 July 27th 06 04:16 PM
XML file extensions Rowan Excel Discussion (Misc queries) 2 April 22nd 05 07:54 AM


All times are GMT +1. The time now is 03:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"