Jump to content

Copy PDFs from a variable folder to a folder on the Desktop [Beginner Question]

Recommended Posts


Hey Everybody,

as you know im on a very low autoit-level.

My question is: How can i read all PDFs from a Folder wich is open and copy them to a Folder on a Desktop.


The Folder wich contains the PDFs is variable Z:\Projektls\"*"*"*EVERYTIME ANOTHER ENDING"*"*"*"*"
There can be 1 PDF or even 15 PDFs.

i tried it with _FileListToArray and _FileCopy but i Need some help to understand this language :)




Share this post

Link to post
Share on other sites
4 minutes ago, Mag91 said:

i tried it with _FileListToArray and _FileCopy but i Need some help to understand this language

Show what you have as else people have to type up all the code for you, which is the wrong way to learn.


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
Live for the present,
Dream of the future,
Learn from the past.

Share this post

Link to post
Share on other sites

Just a form with a start Button
Than he take a variable number from a Excel list and copy it.

the variable number is the projectpath where he has to find the PDFs


i want to make him write the variable number in the Explorer after the path.

i made it with mouseclick and it worked but i want to find a bette way, so i tried

$HWND = WinWaitActive("Projektdetails", "")
ControlClick($HWND, "", "[CLASSNN:ToolbarWindow322; INSTANCE:2; ID:1287]", "LEFT", 1)

but it doesnt work.

But thats not my main Problem i can handle this with mouseclick.

My main Problem is that i have to find the PDFs and copy them to a Folder on the desktop

I tried _FileListToArray and _FileCopy  but i delete it cause i have no idea how it can work.

Here my full code until now.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("BigBag", 188, 48, 553, 270)
$Button1 = GUICtrlCreateButton("Start", 8, 8, 169, 33)
#EndRegion ### END Koda GUI section ###

HotKeySet("{F10}", "stop")

Func STOP()
While 1

While 2
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE

        Case $Button1 ;Start

;=============Find Project===============
sleep (2000)

If ProcessExists ("EXCEL.EXE") Then
    WinActivate ("BigBag_ab_31.01.17.xlsx - Excel")
sleep (500)
Send("{CTRLDOWN}c{CTRLUP}")                                     ;COPY PROJECT NUMBER FROM EXCEL
sleep (500)

ShellExecute ("Z:\Projektdetails\")
WinWaitActive ("Projektdetails", "Projektdetails", 10)
WinMove ("Projektdetails", "", 0, 0, 1000, 750)
sleep (100)
$HWND = WinWaitActive("Projektdetails", "")
ControlClick($HWND, "", "[CLASSNN:ToolbarWindow322; INSTANCE:2; ID:1287]", "LEFT", 1)




Share this post

Link to post
Share on other sites

Don't you prefer to read the excel cell without being forced to have Excel running?

Try This:

; ===========================================================================================
; Include the Excel's udf
; ===========================================================================================
#include <ExcelConstants.au3>
#include <Excel.au3>
#include <FileConstants.au3>
#include <File.au3>

; ===========================================================================================
; Let's going to define where is the Excel file with the information. In case it doesn't exists
; your script will ask you for it.
; ===========================================================================================
Global $ePath = @ScriptDir & "\Test.xlsx"

If Not FileExists($ePath) Then
    $ePath = FileOpenDialog("Select the Excel file", @ScriptDir & "\", "Excel (*.xls;*.xlsx)", $FD_FILEMUSTEXIST)
    If @error Then
        TrayTip("ERROR", "I can't work without a valid Excel file", 0, 2)

; Now we are going to open the Excel file. Take a look at the help file to understand everything.
$1 = _Excel_Open(False, False, False, False, Default)

Global $oExcel = _Excel_BookOpen($1, $ePath, True, Default, Default, Default, Default)

; Change the Sheet name or the cell acording to your excel file.
Global $pathtopdfs = _Excel_RangeRead($oExcel, "Sheet1", "A1")

If Not @error Then ; If everything has gone fine, then now we can close the Excel object

    MsgBox(0, "Path to the pdf folder", $pathtopdfs) ;

    ; As we don't know if the path to the pdfs has a backslash or not, we are gooing to check it
    If StringRight($pathtopdfs, 1) <> "/" Then $pathtopdfs = $pathtopdfs & "\"

    ; Now we are going to check if this path does exist and how many pdf's file are there inside
    If Not FileExists($pathtopdfs) Then
        MsgBox(0, "ERROR!!", "The folder with the pdf's doesn't exist!!!")
        Local $aFileList = _FileListToArray($pathtopdfs, "*.pdf")
        If @error = 1 Then
            MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        If @error = 4 Then
            MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")

        ; If we have found pdf's files inside the path, then we will show them in an array and we will
        ; copy them to the desired folder.
        ; Maybe it would be faster to copy the whole dir, but if you do like this (inside a loop), you'll
        ; only copy the pdf's files and not any other kind of file that could be in $pathtopdfs
        _ArrayDisplay($aFileList, "PDF File(s) Found:")

        For $a = 1 To $aFileList[0] Step 1
            FileCopy($pathtopdfs & $aFileList[$a], @DesktopDir & "\PDF\", 8)


Welcome to the Autoit comunity :bye:


Greets from Barcelona

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

  • Similar Content

    • Epic007
      By Epic007
      Hey guys I'm stuck with a program.....I need a make an automation which copies text from a chat bot app and paste it in notepad to log the replies of my chat bot and to analyse stuff....a lil help pls
      Thanks in advance
    • AnonymousX
      By AnonymousX
      I'm trying to write a script that moves copies excel cells into an array. I'll than manipulate the values and send array into another program. 
      I don't want range to be specific to a workbook, or sheet, or set of cells.
      I want user to be able to highlight desired cells and to copy either normally ("Ctrl+C") or by a hotkey ("Alt+C"). 
      Could someone help me with this?
      Thank you,
      I've tried to write the framework: (edited)
      #include <MsgBoxConstants.au3> #include <Array.au3> #include <Excel.au3> HotKeySet("!v", "Pastedata") While True Sleep(1000) WEnd func Makearray() local $bArray ;User has cells already copied ;Convert clipboard into an array ;I don;t know how excel stores data to clipboard so don;t know how to bring it into array _Arraydisplay($bArray) MsgBox(0,0,$bArray) return $bArray endfunc func Pastedata() Local $aArray MsgBox(0,0,"wait",1) ;make array based on assumption user has already copied a range to clipboard $aArray = Makearray() ;paste code ;don;t worry about this I got the rest endfunc  
    • stafe
      By stafe
      I am trying to get chrome to save it's current webpage to a pdf using autoit.  I wold like to save the file into a folder on the desktop called "ChromeFiles" .  However when I use the send command chrome only occasionally responds.
      Thank you
    • dadalt95
      By dadalt95
      I want to get the signal in this website:
      I have tried using _IEBodyReadText  and some _StringBetween. What happens is that the text are being update every tick and _IEBodyReadText doesn't.
      To perform the update I used  _IEAction($oIE, "refresh") but it's not good because the website block me after some time due too many requests..
      Is there any other way to get this text every tick?
      PS: The text I want to get is WAIT, CALL or PUT.
      Here is the code:
      global $oIE = _IECreate ('https://binary-signal.com/pt/chart/eurusd', 0, 1 , 1 , 0) Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') ;MsgBox ( 0, "asf", $result[0]) $espera=StringInStr($result[0], "WAIT") $compra=StringInStr($result[0], "CALL") $venda=StringInStr($result[0], "PUT") ;MsgBox($MB_SYSTEMMODAL, "", $espera) $n=0 $c=0 Captar() Func Captar() ;_IENavigate($oIE, "https://binary-signal.com/pt/chart/eurusd") ;MsgBox($MB_SYSTEMMODAL, "", $n) Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') If (Not $compra=0) And $n=0 Then MsgBox($MB_SYSTEMMODAL, "", "COMPRE") $n=1 $c=$c+1 ;_IEAction($oIE, "refresh") Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=0 Then MsgBox($MB_SYSTEMMODAL, "", "VENDA") $c=$c+1 $n=1 ;_IEAction($oIE, "refresh") ;MsgBox($MB_SYSTEMMODAL, "", $n) Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Esperando próxima rodada") $n=1 ;MsgBox($MB_SYSTEMMODAL, "", $n) ;_IEAction($oIE, "refresh") Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Esperando próxima rodada") $n=1 ;MsgBox($MB_SYSTEMMODAL, "", $n) ;_IEAction($oIE, "refresh") Sleep(60000) Captar() Else ;MsgBox("", "", "ESPERE") $n=0 Sleep(1000) ;_IEAction($oIE, "refresh") Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') Captar() EndIf EndFunc  
    • nacerbaaziz
      By nacerbaaziz
      I have a query please
      It is about windows file explorer
      If i design a tool in autoit language to delete files for example
      and i  added it in the context menu in File Explorer
      If i right-click on any file And you choose the tool, it will be get the path of the selected file or folder
      The problem here is
      If i select a set of files or folders
      it only detect the first one
      The code that i  used is
      if $CMDLine[0] = 0 then
      msgBox(16, "error", "you don't selecte any files")
      for $i = 1 to $CMDLine[0]
      msgBox(0, "files", $CMDLine[$i]