Jump to content

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


qassam
 Share

Go to solution Solved by SmOke_N,

Recommended Posts

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  

Link to comment
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. :)

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

 

Link to comment
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 !! 

Link to comment
Share on other sites

  • Moderators
  • Solution

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

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.

Link to comment
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

 

Link to comment
Share on other sites

  • Moderators

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

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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. ;)

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

 

Link to comment
Share on other sites

  • Moderators

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...

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

  • Moderators

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.

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.

Link to comment
Share on other sites

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

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

Link to comment
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

 

Link to comment
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 ?? 

Link to comment
Share on other sites

  • Moderators

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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

 

Link to comment
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. ;)

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

Link to comment
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

 

Link to comment
Share on other sites

  • 2 weeks later...

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 ;) 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...