Sign in to follow this  
Followers 0
qassam

need help about find *.jpg files from all drivers and copy them !!

19 posts in this topic

hello all ... i want to write a code do the following :

1-find all drivers in windows 

2-search all drivers for any *.jpg files and then copy all of them ( founded files in all drivers to some folder created by me ) 

i dont now how to do this please help me i read some topics about _FileListToArray but i didnt understand how to make a copy after search and put all files in some folder in my desktop ..... etc 

help me please >>>>

regards  

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The place you need to look to find your drivers, if your on win 7 (let me know if this is different) is: C:\Windows\System32\DriverStore

Local $path ="C:\Windows\System32\DriverStore", $filter = "*.jpg"
 
_FileListToArray($path, $filter, 1)
 

That will list your files like so

Return Value Success: A one-dimensional array.
    $aArray[0] = Number of FilesFolders returned
    $aArray[1] = 1st FileFolder
    $aArray[2] = 2nd FileFolder
    $aArray[3] = 3rd FileFolder
    $aArray[n] = nth FileFolder      

 

Then you'll need to use FileMove or FileCopy after you have used DirCreate to make the folder. This can be done with a for loop on the number of files read with $aArray[0]. ;)

Give it a try and if you have any questions post them. :)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

The place you need to look to find your drivers, if your on win 7 (let me know if this is different) is: C:\Windows\System32\DriverStore

Local $path ="C:\Windows\System32\DriverStore", $filter = "*.jpg"
 
_FileListToArray($path, $filter, 1)
 

That will list your files like so

Return Value Success: A one-dimensional array.

    $aArray[0] = Number of FilesFolders returned

    $aArray[1] = 1st FileFolder

    $aArray[2] = 2nd FileFolder

    $aArray[3] = 3rd FileFolder

    $aArray[n] = nth FileFolder      

 

Then you'll need to use FileMove or FileCopy after you have used DirCreate to make the folder. This can be done with a for loop on the number of files read with $aArray[0]. ;)

Give it a try and if you have any questions post them. :)

im sorry man i didn't understand what is the relationship between C:WindowsSystem32DriverStore and my topic !! 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You really need to post what you've tried thus far.

This isn't a "write code for me because I've said I've tried" type of forum.

Here is pseudo code to help get you started.

#include <File.au3>

Global $szMyDir = "Drive:\MyDesktop\MyFolder"

; ensure my "to" folder exist
If Not FileExists($szMyDir) Then DirCreate($szMyDir)

; get a list of all drives on computer
Global $gaDrives = DriveGetDrive("ALL")
If Not IsArray($gaDrives) Then
    MsgBox(16 + 262144, "Error", "Could not get drives!")
    Exit
EndIf

; loop through drives and use recursive search to 
;  loop through all folders in that drive to find match
Global $gaJPGList = 0
For $iDrives = 1 To UBound($gaDrives) - 1
    $gaJPGList = _FileListToArrayRec($gaDrives[$iDrives], "*.jpg", $FLTAR_FILES, $FLTAR_RECUR, Default, $FLTAR_FULLPATH)
    If Not @error Then
        For $iPic = 1 To UBound($gaJPGList) - 1
            FileCopy($gaJPGList[$iPic], $szMyDir)
        Next
    EndIf
Next

Edit:

Be prepared to wait forever for code to finish.  Never just run code on your PC unless you know exactly what it is doing.

Edit2:

Oops, I had DirCopy instead of FileCopy, that's what I get for typing in this window instead of SciTe lol, fixed above.

And Edit3:

You want to return all files, changed 3rd param of _FileListToArrayRec() to represent that... And I'm done now... Good Luck

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites
1-find all drivers in windows 

 

im sorry man i didn't understand what is the relationship between C:WindowsSystem32DriverStore and my topic !! 

 

It's where all the drivers are located on the system. You asked me where the drivers were located, is this not your actual question?  :sweating:


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Eh, I believe he means from all drives....

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

It's a little hard to understand when they said drivers 3 times..... :geek:

EDIT: if you can understand that you did not mean drivers, why not fix it? :x

That was a rhetorical question. SmOke_N's answer will do the job for you. ;)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Language is obviously a barrier, but in looking at context, I don't think I've ever known anyone to ask for .jpg files embedded inside drivers. It isn't that far a leap...

1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

All that aside.  What happened to expecting effort and teaching someone to fish?  Must be getting close to Christmas.

1 person likes this

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

All that aside.  What happened to expecting effort and teaching someone to fish?  Must be getting close to Christmas.

Indeed... that was a "give a dog a bone" type moment.

1 person likes this

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Agreed, boththose, but I think we've all had those moments :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

that, and Smoke_N's pseudo code puts my actual code to shame


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Language is obviously a barrier, but in looking at context, I don't think I've ever known anyone to ask for .jpg files embedded inside drivers. It isn't that far a leap...

 

Very true. My apologies. JLogan your quote made me laugh after this. ^_^


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

It's a little hard to understand when they said drivers 3 times..... :geek:

EDIT: if you can understand that you did not mean drivers, why not fix it? :x

That was a rhetorical question. SmOke_N's answer will do the job for you. ;)

im sorry for my bad lang. Drivers mean : C: , D: , E: etc .... 

i used this code :

 

#include <MsgBoxConstants.au3>

 
qan()
Func qan()
   local $filter = ( "*.jpg*" )
  local $drivers   = DriveGetDrive("all")
  Local $hSearch = FileFindFirstFile(  $filter )
  local $sFileName = FileFindNextFile($hSearch)
 
 
Local $sFileName = "", $iResult = 0
 
    While 1
        $sFileName = FileFindNextFile($hSearch)
        ; If there is no more file matching the search.
        If @error Then ExitLoop
 
        ; Display the file name.
        $iResult = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "", "File: " & $sFileName , $drivers )
        If $iResult <> $IDOK Then ExitLoop ; If the user clicks on the cancel/close button.
    WEnd
 
    ; Close the search handle.
    FileClose($hSearch)
EndFunc   ;==>Example
 

but its only gives me .jpg on desktop directory ( where i saved the script ) any idea ?? 

Share this post


Link to post
Share on other sites

Why are you not using the code SmOke_N gave you? He handed you exactly what you need to complete the task.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

im sorry for my bad lang. Drivers mean : C: , D: , E: etc .... 

 

No problem, but its Drives not Drivers. ;)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Watch out for Drivers with Jpegs, :blink:

They are a bugger to get out, if you don't stay clear and get hooked. :muttley:

P.S. Sorry, I couldn't resist. :P

A sense of humor ... me ... you must be joking. ;)

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

I took it at face value, and I am a literalist sometimes.

I mean... this is the internet. ha :shifty:


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

You really need to post what you've tried thus far.

This isn't a "write code for me because I've said I've tried" type of forum.

Here is pseudo code to help get you started.

#include <File.au3>

Global $szMyDir = "Drive:\MyDesktop\MyFolder"

; ensure my "to" folder exist
If Not FileExists($szMyDir) Then DirCreate($szMyDir)

; get a list of all drives on computer
Global $gaDrives = DriveGetDrive("ALL")
If Not IsArray($gaDrives) Then
    MsgBox(16 + 262144, "Error", "Could not get drives!")
    Exit
EndIf

; loop through drives and use recursive search to 
;  loop through all folders in that drive to find match
Global $gaJPGList = 0
For $iDrives = 1 To UBound($gaDrives) - 1
    $gaJPGList = _FileListToArrayRec($gaDrives[$iDrives], "*.jpg", $FLTAR_FILES, $FLTAR_RECUR, Default, $FLTAR_FULLPATH)
    If Not @error Then
        For $iPic = 1 To UBound($gaJPGList) - 1
            FileCopy($gaJPGList[$iPic], $szMyDir)
        Next
    EndIf
Next

Edit:

Be prepared to wait forever for code to finish.  Never just run code on your PC unless you know exactly what it is doing.

Edit2:

Oops, I had DirCopy instead of FileCopy, that's what I get for typing in this window instead of SciTe lol, fixed above.

And Edit3:

You want to return all files, changed 3rd param of _FileListToArrayRec() to represent that... And I'm done now... Good Luck

thanks boss it's working ;) 

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