Extensions, Extensions and more Extensions ACCESS just do it

R

rebelscum0000

Dear All,

I want to search for ALL the files which their extensions, looking in
my Entire HD
(In fact I only need the extensions and FileType),
With the following Criteria:
Searching system folders, hidden files and folders, subfolders, also
Windows Folder
Then I want to insert them into a tbl mm.. let's name AllExtension_Tbl
AND
No Duplicates allowed.

In my actual code I populate the tbl reading from a .TXT file, created
for a previous .bat file (Please do not ask me why is a long
history)

The problems are when my recordset find FILES like:

.raidenftpd.acl

.raidenftpd IS NOT an extension!!

but .ACL IS an extension:

--

System Info for File Extension .ACL

Program ID:
ACLFile
aclfile

FileType :
AutoCorrect List File

EXEFile :
%ProgramFiles%\ACL Software\ACL Version 8\ACLWin.exe

--

Finally I want to compare somehow with the following criteria

File Found:

..raidenftpd.acl

Search in the Tbl AllExtension_Tbl

Is .raidenftpd.acl is an extension I have in my actual HD?

IF No then

FileName = .raidenftpd.
FileExtension = .acl
FileType = AutoCorrect List File

IF Yes AND I do not have the extension in the Tbl AllExtension_Tbl in
order to compare then I have "The Problem" because my code
understands

File Name = Null <-Error
FileExtension = .raidenftpd.acl
FileType = <-Error

End If

I do not have idea how to do this any help, idea or suggestion are
more than welcome

Thanks in advance

Regards,

Antonio Macias
 
M

Marco Pagliero

I do not have idea how to do this any help, idea or suggestion are
more than welcome

May I see your code? I would anyway first identfy the extension
beginning from the end and looking for the last point. Also a problem
if the filename has a point somewhere and no extension at all.

Marco P
 
I

i_takeuti

rebelscum0000 said:
Dear All,

I want to search for ALL the files which their extensions, looking in
my Entire HD
(In fact I only need the extensions and FileType),
With the following Criteria:
Searching system folders, hidden files and folders, subfolders, also
Windows Folder
Then I want to insert them into a tbl mm.. let's name AllExtension_Tbl
AND
No Duplicates allowed.

In my actual code I populate the tbl reading from a .TXT file, created
for a previous .bat file (Please do not ask me why is a long
history)

The problems are when my recordset find FILES like:

.raidenftpd.acl

.raidenftpd IS NOT an extension!!

but .ACL IS an extension:

--

System Info for File Extension .ACL

Program ID:
ACLFile
aclfile

FileType :
AutoCorrect List File

EXEFile :
%ProgramFiles%\ACL Software\ACL Version 8\ACLWin.exe

--

Finally I want to compare somehow with the following criteria

File Found:

.raidenftpd.acl

Search in the Tbl AllExtension_Tbl

Is .raidenftpd.acl is an extension I have in my actual HD?

IF No then

FileName = .raidenftpd.
FileExtension = .acl
FileType = AutoCorrect List File

IF Yes AND I do not have the extension in the Tbl AllExtension_Tbl in
order to compare then I have "The Problem" because my code
understands

File Name = Null <-Error
FileExtension = .raidenftpd.acl
FileType = <-Error

End If

I do not have idea how to do this any help, idea or suggestion are
more than welcome

Thanks in advance

Regards,

Antonio Macias
 
R

rebelscum0000

May I see your code?

Sure ..

Thanks in advance
Regards,
Antonio Macias

Replace_First_Process:

'Initialize New Event "Replace_First_Process"
Dim sQL19 As String
Dim sQL20 As String
Dim sQL22 As String
Dim MyTempDataCount As Integer
Dim MyTempDataID As Integer
Dim MyDirHashFiles As String
Dim MyDirPathOnly As String
Dim MyHash As String
Dim MyFileExtensions As String
Dim MyFileOnly As String
Dim MyExtensionOnly As String
Dim MyFilesinDir As Integer
Dim MyDataProcess As Boolean
Dim MyFileExtensionsCheck As Boolean
Dim MyFileExtensionsFix As Boolean
Dim MyFileFix As Boolean
Dim MyExtensionsFix As Boolean
Dim MyFileExtensionsProblem As Boolean
Dim MyFileProblem As Boolean
Dim MyExtensionsProblem As Boolean
Dim V As Integer


'Use the TempDataTemp_Tbl to replace the records of the Tbl
TempData_Tbl, and start again
'Skips Writing out a batch file Process, Rem sQL21 & sQL22, Start the
code from "Replace First Process"
'INSERT INTO TempDataTemp_Tbl All the Field Names and Records FROM
TempData_Tbl ORDER BY TempData_Tbl.ID
sQL22 = _
"INSERT INTO TempDataTemp_Tbl ( ID, DirHashFiles, DirPathOnly, Hash,
FileExtensions, FileOnly, ExtensionOnly, FilesinDir, DataProcess,
FileExtensionsCheck, FileExtensionsFix, FileFix, ExtensionsFix,
FileExtensionsProblem, FileProblem, ExtensionsProblem ) " & _
"SELECT TempData_Tbl.ID, TempData_Tbl.DirHashFiles,
TempData_Tbl.DirPathOnly, TempData_Tbl.Hash, " & _
"TempData_Tbl.FileExtensions, TempData_Tbl.FileOnly,
TempData_Tbl.ExtensionOnly, " & _
"TempData_Tbl.FilesinDir, TempData_Tbl.DataProcess,
TempData_Tbl.FileExtensionsCheck, " & _
"TempData_Tbl.FileExtensionsFix, TempData_Tbl.FileFix,
TempData_Tbl.ExtensionsFix, " & _
"TempData_Tbl.FileExtensionsProblem, TempData_Tbl.FileProblem,
TempData_Tbl.ExtensionsProblem " & _
"FROM TempData_Tbl " & _
"ORDER BY TempData_Tbl.ID; "

CurrentDb.Execute sQL22, dbFailOnError

'Select Only the Records From the Tbl empData_Tbl WHERE DirHashFiles
Not Like DIR & DataProcess = 0
sQL19 = _
"SELECT TempData_Tbl.ID, TempData_Tbl.DirHashFiles,
TempData_Tbl.DirPathOnly, TempData_Tbl.Hash, " & _
"TempData_Tbl.FileExtensions, TempData_Tbl.FileOnly,
TempData_Tbl.ExtensionOnly, TempData_Tbl.FilesinDir, " & _
"TempData_Tbl.DataProcess, TempData_Tbl.FileExtensionsCheck,
TempData_Tbl.FileExtensionsFix, " & _
"TempData_Tbl.FileFix, TempData_Tbl.ExtensionsFix,
TempData_Tbl.FileExtensionsProblem, " & _
"TempData_Tbl.FileProblem, TempData_Tbl.ExtensionsProblem " & _
"From TempData_Tbl " & _
"WHERE TempData_Tbl.DirHashFiles Not Like 'DIR*' AND
TempData_Tbl.DataProcess = 0 "

'Initialize Variables
MyTempDataCount = DCount("[ID]", "TempData_Tbl", "[DirHashFiles] Not
Like 'DIR*' AND [DataProcess] = 0 ")

Set ccgdb = CurrentDb
Set ccgrs = ccgdb.OpenRecordset(sQL19, dbOpenDynaset)

For V = 1 To MyTempDataCount

MyTempDataID = ccgrs.Fields("ID")
MyDirHashFiles = ccgrs.Fields("DirHashFiles")
MyFileExtensionsFix = ccgrs.Fields("FileExtensionsFix")

'MsgBox "My iD = " & MyTempDataID & " And My Hash is " &
MyDirHashFiles

'Gets Hash or what is before the space
MyHash = Left$(MyDirHashFiles, InStr(MyDirHashFiles, " ") - 1)
'Gets File with its extension or what is after the space

MyFileExtensions = Mid$(MyDirHashFiles, InStr(MyDirHashFiles, " ") +
1)
'Only File

MyFileOnly = Left$(MyFileExtensions, InStr(MyFileExtensions, ".") - 1)
'Only Extension Or Extensions
MyExtensionsOnly = Mid$(MyFileExtensions, InStr(MyFileExtensions, ".")
+ 1) 'MyExtensionsOnly = Mid$(MyFileExtensions,
InStrRev(MyFileExtensions, ".") + 1)

'Replaces Hash, FileExtensions, ExtensionOnly (Also Adds a period at
the beginning of the string)
'Where ID = MyTempDataID AND DirHashFiles Is Not Like DIR AND
DataProcess = 0
sQL20 = _
"UPDATE TempData_Tbl SET TempData_Tbl.Hash = """ & MyHash & """, " & _
"TempData_Tbl.FileExtensions = """ & MyFileExtensions & """, " & _
"TempData_Tbl.FileOnly = """ & MyFileOnly & """, " & _
"TempData_Tbl.ExtensionOnly = '.' & """ & MyExtensionsOnly & """ " & _
"WHERE TempData_Tbl.ID = " & MyTempDataID & " AND
TempData_Tbl.DirHashFiles Not Like 'DIR*' AND TempData_Tbl.DataProcess
= 0 "

'Debug.Print sQL20
CurrentDb.Execute sQL20, dbFailOnError

ccgrs.MoveNext

Next V
 
M

Marco Pagliero

[..]
I'm sorry but I don't understand what you are traying to do with
TempDataTemp_Tbl.

Anyway it seems to me that ID in TempData_Tbl should be unique, that
is: there are no two records with the same ID. Then you can update the
record directly:

For V = 1 To MyTempDataCount
[..]
'Only Extension with period.
MyExtensionsOnly = Mid$(MyFileExtensions,
InStrRev(MyFileExtensions, ".") )

'Replaces Hash, FileExtensions, ExtensionOnly

ccgrs.edit 'Change values directly
ccgrs.Fields("Hash") = MyHash
ccgrs.Fields("FileExtensions") = MyFileExtensions
ccgrs.Fields("FileOnly") = MyFileOnly
ccgrs.Fields("ExtensionOnly") = MyExtensionsOnly
ccgrs.update

ccgrs.MoveNext
Next V

You can get the error massage that it is forbidden to put empty
strings in the record. Then you have to change the field property
"AllowZeroLength" to "true" in the table, or put this lines before
"ccgrs.edit "

if len(MyHash)=0 then MyHash="-"
if len(FileExtensions)=0 then FileExtensions="-"
if len(FileOnly)=0 then FileOnly="-"
if len(ExtensionOnly)=0 then ExtensionOnly="-"

Beside that I think that the following way to write very long lines
should also work, and it is not so heavy and prone to typos:

sQL19 = "SELECT * From TempData_Tbl "
sQL19 = sQL19 + "WHERE TempData_Tbl.DirHashFiles "
sQL19 = sQL19 + "Not Like 'DIR*' AND TempData_Tbl.DataProcess = 0 "

Greetings
Marco P
 
M

Marco Pagliero

if len(MyHash)=0 then MyHash="-"
if len(FileExtensions)=0 then FileExtensions="-"
if len(FileOnly)=0 then FileOnly="-"
if len(ExtensionOnly)=0 then ExtensionOnly="-"

Sorry again, this is of course:
if len(MyHash)=0 then MyHash="-"
if len(MyFileExtensions)=0 then MyFileExtensions="-"
if len(MyFileOnly)=0 then MyFileOnly="-"
if len(MyExtensionOnly)=0 then MyExtensionOnly="-"

Marco P
 

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

Top