Jump to content
Sign in to follow this  
bobheart

Just a little help if you could

Recommended Posts

bobheart

I have this working till i get to the point to pick a folder to save it to and I start getting errors ?

See whats wrong?

Trying to make a backup app .

$message = "Hold down Ctrl or Shift to choose multiple files."

$var = FileOpenDialog($message, "C:\Windows", "files (*.*)", 1 + 4 )

MsgBox(0,"","You entered " & $var & ".")

$var = FileSaveDialog( "Choose a name.", $MyDocsFolder, "Scripts (*.*;*.*)", 3)

DirCopy("& $OutputVar &", "have folder to add here var?", 1)

If @error Then

    MsgBox(4096,"","Save cancelled.")

Else

    MsgBox(4096,"","You chose " & $var)

EndIf

Share this post


Link to post
Share on other sites
bobheart

Thank you Cyber that help me a lot , I get no errors now but the file does not get copyed ?

How would I make it so it would list the files with names right now it is asking when it saves to name it ?

$message = "Hold down Ctrl or Shift to choose multiple files."

Dim $MyDocsFolder,$backupfolder,$OutputVar

$var = FileOpenDialog($message, "C:\Windows", "files (*.*)", 1 + 4 )

MsgBox(0,"","You entered " & $var & ".")

$var = FileSaveDialog( "Choose a name.", $MyDocsFolder, "Scripts (*.*;*.*)", 3)

DirCopy($OutputVar , $backupfolder, 1)

If @error Then

    MsgBox(4096,"","Save cancelled.")

Else

    MsgBox(4096,"","You chose " & $var)

EndIf

Edited by bobheart

Share this post


Link to post
Share on other sites
Lazycat

I don't see where you set value into $OutputVar and $backupfolder. So you copy nothing into nothing. But anyway, DirCopy will copy all files in all subfolders, not only you selected by FileOpenDialog, so probably this is not suitable here. You can use StringSplit to get multiselected file list:

$var = FileOpenDialog($message, "C:\Windows", "files (*.*)", 1 + 4 )
$list = StringSplit($var, "|")

Where

$list[0] - count of array items

$list[1] - full path to files

$list[2] - $list[ $list[0]-2 ] all selected files

So you can build full path for each file

For $i = 2 to $list[0]
    $curpath = $list[1] & "\" & $list[$i]
; You code to handle filename here
Next

Share this post


Link to post
Share on other sites
bobheart

Well don't go by what I have as I'm trying to do this and not real sure what I'm doing so any help is fine with me .

What I have now and feel free to add or fix . thanks for any help

$message = "Hold down Ctrl or Shift to choose multiple files."

Dim $MyDocsFolder,$backupfolder,$OutputVar

$var = FileOpenDialog($message, "C:\Windows", "files (*.*)", 1 + 4 )

$list = StringSplit($var, "|")

MsgBox(0,"","You entered " & $var & ".")

$var = FileSaveDialog( "Choose a name.", $MyDocsFolder, "Scripts (*.*;*.*)", 3)

DirCopy($OutputVar , $backupfolder, 1)

For $i = 2 to $list[0]    $curpath = $list[1] & "\" & $list[$i]

; You code to handle filename here

Next

If @error Then

    MsgBox(4096,"","Save cancelled.")

Else

    MsgBox(4096,"","You chose " & $var)

EndIf

Still not copying the file

Share this post


Link to post
Share on other sites
bobheart

***********bump*********

Share this post


Link to post
Share on other sites
SlimShady

I changed the things I could change, but like Kot said:

I don't see where you set value into $OutputVar and $backupfolder. So you copy nothing into nothing.

<{POST_SNAPBACK}>

$message = "Hold down Ctrl or Shift to choose multiple files."
Dim $backupfolder,$OutputVar
$var = FileOpenDialog($message, "C:\Windows", "files (*.*)", 1 + 4 )
$list = StringSplit($var, "|")
MsgBox(0,"","You entered " & $var & ".")
$var = FileSaveDialog( "Choose a name.", @MyDocumentsDir, "Scripts (*.*)", 3)
DirCopy($OutputVar , $backupfolder, 1)
For $i = 2 to $list[0]
    $curpath = $list[1] & "\" & $list[$i]
; You code to handle filename here
Next
If @error Then
    MsgBox(4096,"","Save cancelled.")
Else
    MsgBox(4096,"","You chose " & $var)
EndIf

Share this post


Link to post
Share on other sites
bobheart

Still no copy one file to other folder ?

Share this post


Link to post
Share on other sites
Lazycat

All problems are because we don't understand what you want to do. I see, you select some files in the C:\Windows folder. Next you select some folder into $MyDocsFolder. What next? What you want to copy and where to? A some explanation give us a chance to help you.

Share this post


Link to post
Share on other sites
bobheart

Well I want tp pick a folder to copy and pick a place to copy it to .

Share this post


Link to post
Share on other sites
SlimShady

Well I want tp pick a folder to copy and pick a place to copy it to .

<{POST_SNAPBACK}>

I see now.

Here's what I made.

$message = "Hold down Ctrl or Shift to choose multiple files."
$files = FileOpenDialog($message, "C:\Windows", "files (*.*)", 1 + 4 )
If @error Then Exit
MsgBox(0,"","You chose " & $files & ".")
$list = StringSplit($files, "|")
$folder = FileSelectFolder("Choose a directory to backup to", @MyDocumentsDir)
If @error Then
    MsgBox(4096,"","Backup cancelled.")
Else
    MsgBox(4096,"","You chose " & $folder)
EndIf
For $i = 2 to $list[0]
    FileCopy($list[1] & "\" & $list[$i], $folder "\" & $list[$i], 1)
Next

Share this post


Link to post
Share on other sites
bobheart

Got to the point to pick a folder to copy to and got this error ?

---------------------------

AutoIt Error

---------------------------

Line 6 (File "C:\Documents and Settings\bob\My Documents\backup.au3"):

$folder = FileSelectFolder("Choose a directory to backup to", @MyDocumentsDir)

$folder = ^ ERROR

Error: Incorrect number of parameters in function call.

Edited by bobheart

Share this post


Link to post
Share on other sites
bobheart

Found the error . added the "",

$folder = FileSelectFolder("Choose a directory to backup to","", @MyDocumentsDir)

But it still does not copy files ?

Share this post


Link to post
Share on other sites
Jos

Found the error . added the "",

$folder = FileSelectFolder("Choose a directory to backup to","", @MyDocumentsDir)

But it still  does not copy files ?

<{POST_SNAPBACK}>

Previous syntax was correct : FileSelectFolder ( "dialog text", "root dir" [, flag] )

This doesn't look ok to me:

$folder = FileSelectFolder("Choose a directory to backup to","", @MyDocumentsDir)

:ph34r:


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                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
bobheart

Well what do you think it needs ? :ph34r:

Share this post


Link to post
Share on other sites
Jos

Well what do you think it needs ? :(

<{POST_SNAPBACK}>

need to see the whole script to see what the issue could be....

:ph34r:


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                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
bobheart

$message = "Hold down Ctrl or Shift to choose multiple files."

$files = FileOpenDialog($message, "C:\", "files (*.*)", 1 + 4 )

If @error Then Exit

MsgBox(0,"","You chose " & $files & ".")

$list = StringSplit($files, "|")

$folder = FileSelectFolder("Choose a directory to backup to","", @MyDocumentsDir)

If @error Then

    MsgBox(4096,"","Backup cancelled.")

Else

    MsgBox(4096,"","You chose " & $folder)

EndIf

For $i = 2 to $list[0]    FileCopy($list[1] & "\" & $list[$i], $folder "\" & $list[$i], 1)

Next

Share this post


Link to post
Share on other sites
Lazycat

Hmm... maybe this variant will be ok? It should copy selected files (or single file) into picked dir.

$message = "Hold down Ctrl or Shift to choose multiple files."
$files = FileOpenDialog($message, "C:\Windows", "files (*.*)", 1 + 4 )
If @error Then Exit
MsgBox(0,"","You chose " & $files & ".")
$list = StringSplit($files, "|")
$folder = FileSelectFolder("Choose a directory to backup to", @MyDocumentsDir)
If @error Then
    MsgBox(4096,"","Backup cancelled.")
Else
    MsgBox(4096,"","You chose " & $folder)
EndIf
If $list[0] = 1 Then
    $temp = StringSplit($list[1], "\")
    FileCopy($list[1], $folder & "\" & $temp[$temp[0]], 1)
Else
    For $i = 2 to $list[0]
        FileCopy($list[1] & "\" & $list[$i], $folder & "\" & $list[$i], 1)
    Next
Endif

Share this post


Link to post
Share on other sites
Jos

there is a different error in this script on line 15 ... an & is missing

this version works for me:

$message = "Hold down Ctrl or Shift to choose multiple files."
$files = FileOpenDialog($message, "C:\", "files (*.*)", 1 + 4 )
If @error Then Exit
MsgBox(0,"","You chose " & $files & ".")
$list = StringSplit($files, "|")
$folder = FileSelectFolder("Choose a directory to backup to", @MyDocumentsDir)
If @error Then
    MsgBox(4096,"","Backup cancelled.")
Else
    MsgBox(4096,"","You chose " & $folder)
EndIf
For $i = 2 to $list[0]
    FileCopy($list[1] & "\" & $list[$i], $folder & "\" & $list[$i], 1)
Next

:ph34r:


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                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

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  

×