Sign in to follow this  
Followers 0
Tanelorn

Find corrupt files

10 posts in this topic

#1 ·  Posted (edited)

Hello Commmunity..

My Situation:

I have got about 10.000 Files, mostly MS Office and PDF Files, where a great amount of it seems to be on the one hand corrupt or just password protected.

These files are present in a shared folder, within several subfolders. I got a list with the specific file names an paths..

My Job:

"Please find out which files are Password protected, really corrupt, maybe saved with an older MS Office version [...], send me an excel sheet with the fürther information of your tested files: e.g. Path, Filename, Error /(protected, corrupt, wrong version)"

My Problem:

FFS There are over 10.000 (ten thousand!) documents! I imagine that its nearly impossible to pick every document, open it and write down the error state! this would take.. errrm for each file about.. err.. 2 minutes.. 2 minutes.. 10.000 docs.. 20.000 minutes... 8h a day @ work ... thats about 5 business weeks . . .

My Idea: ....

1. Feed AutoIT with a list of files..

2. AutoIT opens the 1st file in list..

3. scans the opened window for specific errors..

4. these are controled with a list ( "Enter Your passwort" in content = "password protected")

5. write the keyword "password protected" into a new excel list, adding it to the filepath and name;

5.1. if theres no fitting type at this list, take the error screen message and add this one.

5.2 if there is no error screen. type "Okay" into the excel sheet

6. Close file

7. open next file ....

8. see 1.

.

.

.

Can someone help me? i do not have the experience with this tool, so i cannot do this on my own.

I got a tipp to use this community forum,because the AutoIT tool is a very mighty one..

It would be great if someonecould help me.

Thanky Folks,

Chris

Edited by Tanelorn

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

2 task : one for office (word, excel), one for pdf files

for word /excel

-there are autoit UDFs , so try to open, see if it fails or if its ok , when ok -all good, when failure - try to find out why (what error is displayed then? )

for pdfs:

- for a first start maybe try to open with acrobat , then try to find the "error" messages if any ..

or

try a pdf2html tool like

http://pdftohtml.sourceforge.net/

and check if there will be any valid text on the html

- but it would be best to use a pdf validator here i think , maybe try something like

http://www.pdfworkflows.com/products.htm

Edited by nobbe

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hello Commmunity..

My Situation:

I have got about 10.000 Files, mostly MS Office and PDF Files, where a great amount of it seems to be on the one hand corrupt or just password protected.

These files are present in a shared folder, within several subfolders. I got a list with the specific file names an paths..

My Job:

"Please find out which files are Password protected, really corrupt, maybe saved with an older MS Office version [...], send me an excel sheet with the fürther information of your tested files: e.g. Path, Filename, Error /(protected, corrupt, wrong version)"

My Problem:

FFS There are over 10.000 (ten thousand!) documents! I imagine that its nearly impossible to pick every document, open it and write down the error state! this would take.. errrm for each file about.. err.. 2 minutes.. 2 minutes.. 10.000 docs.. 20.000 minutes... 8h a day @ work ... thats about 5 business weeks . . .

My Idea: ....

1. Feed AutoIT with a list of files..

2. AutoIT opens the 1st file in list..

3. scans the opened window for specific errors..

4. these are controled with a list ( "Enter Your passwort" in content = "password protected")

5. write the keyword "password protected" into a new excel list, adding it to the filepath and name;

5.1. if theres no fitting type at this list, take the error screen message and add this one.

5.2 if there is no error screen. type "Okay" into the excel sheet

6. Close file

7. open next file ....

8. see 1.

.

.

.

Can someone help me? i do not have the experience with this tool, so i cannot do this on my own.

I got a tipp to use this community forum,because the AutoIT tool is a very mighty one..

It would be great if someonecould help me.

Thanky Folks,

Chris

Well this is quite simple... finding the files is very simple but since I dont have them or anything similar can u tell me the window title of password protected ones?

This would open a file and if the winexists, meaning its asking for a password then it returns it as password protected

Here's an example of all I could do with the info given :)

#include <file.au3>

$dir = "";the folder directory were the files all, put them all in one folder
$passprotectdir = $dir & "passprotected\";were the files after checked will be moved if passprotected
$corrupteddir = $dir & "corrupted\";were the files after checked will be moved if corrupted
DirCreate($passprotectdir);create the passprotected folder
DirCreate($corrupteddir);create the corrupted folder

$files = FileFindFirstFile($dir & "*");find first file
Do;Do a loop selecting a file and then testing it
    $file = FileFindNextFile($files)
    Run($file)
    If WinExists() Then;if the enter password screen comes up
        WinClose();Close it
        FileMove($file, $passprotectdir);Move to password protected folder
    Else;else not passprotected
        FileMove($file, $corrupteddir);Move to corrupted folder
    EndIf
Until $file = "";Untill no more files to check
Edited by tlokz

Share this post


Link to post
Share on other sites

Hey Great thank you!

but there are 2 further problems i found if i would use your code:

1.)

there are files with same names for example.. and i have to keep the original path name, is this possible? eg: corruptedfolder\orgsubfolder1\orgsubfolder2\orgsubfolder3\file.ext

2.)

there are as i intent the following "error states" possible:

- protected

- corrupt

- wrong version

- not corrupt; can be opened without problems

But your answer helps me some greater steps towards the final solution!! Great!

Yours Chris

Share this post


Link to post
Share on other sites

That will change that :)

$passprotectdir = $dir & "passprotected\anotherfolder\"

For protected get the window title of it when it comes up...

For corrupt... not sure how what happens so not sure

Wrong version... how u checking this?

This will be the else so if none of these problems happen then its good

Also, this will check all files... including those of the same name.. it will keep checking them untill no files exist in that folder no more

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

ok then ill have a try^^

but one further question.. if the e.g. password windowtitle is "passwort title" where would i put this ? :-(

WinExists(passwort title) ??

@ nobbe: thy for your post, this has solved my problem for the pdf files ;-)

Edited by Tanelorn

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

ok then ill have a try^^

but one further question.. if the e.g. password windowtitle is "passwort title" where would i put this ? :-(

WinExists(passwort title) ??

yup but with ""

WinExists("passwort title")

Here's a little more to leave you with

#include <file.au3>

$dir = "";the folder directory were the files all, put them all in one folder
$passprotectdir = $dir & "passprotected\";were the files after checked will be moved if passprotected
$corrupteddir = $dir & "corrupted\";were the files after checked will be moved if corrupted
$finedir = $dir & "fine\";were the files after checked will be moved if corrupted
DirCreate($passprotectdir);create the passprotected folder
DirCreate($corrupteddir);create the corrupted folder
DirCreate($finedir)

$files = FileFindFirstFile($dir & "*");find first file
Do;Do a loop selecting a file and then testing it
    $file = FileFindNextFile($files)
    RunWait($file)
    If WinExists("passwort title") Then;if the enter password screen comes up
        WinClose("passwort title");Close it
        FileMove($file, $passprotectdir);Move to password protected folder
    ElseIf WinExists("corrupt");corrupted win title
        WinClose("corrupt");Close it
        FileMove($file, $corrupteddir);Move to corrupted folder
    Else;else fine
        FileMove($file, $finedir);Move to fine folder
    EndIf
Until $file = "";Untill no more files to check
Edited by tlokz

Share this post


Link to post
Share on other sites

Youre great^^

ah i can use wildcards for the tile like "*password*" do i?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

hm ok.. i tested it an the procedure is nice ... but.. it seems not to recognize the window title .. could it maybe mean an internal title? or can i work with 5te internal class like #32770 für Concert/open Database (Access)

Edited by Tanelorn

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

hm ok.. i tested it an the procedure is nice ... but.. it seems not to recognize the window title .. could it maybe mean an internal title? or can i work with 5te internal class like #32770 für Concert/open Database (Access)

Use the auto window info tool to properly get the win title

Best way is to just get the window title, same one that would show up in task manager for it :) That way it looks for that one thing becuase anything else and it could change from window to window

Edited by tlokz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0