bobheart Posted August 20, 2004 Share Posted August 20, 2004 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 Link to comment Share on other sites More sharing options...
CyberSlug Posted August 20, 2004 Share Posted August 20, 2004 $MyDocsFolder is not declared Also, check the quotes in the DirCopy stament..... I don't think $OutputVar should be inside them Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
bobheart Posted August 20, 2004 Author Share Posted August 20, 2004 (edited) 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 August 20, 2004 by bobheart Link to comment Share on other sites More sharing options...
Lazycat Posted August 20, 2004 Share Posted August 20, 2004 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 Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
bobheart Posted August 20, 2004 Author Share Posted August 20, 2004 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) EndIfStill not copying the file Link to comment Share on other sites More sharing options...
bobheart Posted August 20, 2004 Author Share Posted August 20, 2004 ***********bump********* Link to comment Share on other sites More sharing options...
SlimShady Posted August 20, 2004 Share Posted August 20, 2004 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 Link to comment Share on other sites More sharing options...
bobheart Posted August 20, 2004 Author Share Posted August 20, 2004 Still no copy one file to other folder ? Link to comment Share on other sites More sharing options...
Lazycat Posted August 21, 2004 Share Posted August 21, 2004 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. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
bobheart Posted August 21, 2004 Author Share Posted August 21, 2004 Well I want tp pick a folder to copy and pick a place to copy it to . Link to comment Share on other sites More sharing options...
SlimShady Posted August 21, 2004 Share Posted August 21, 2004 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 Link to comment Share on other sites More sharing options...
bobheart Posted August 21, 2004 Author Share Posted August 21, 2004 (edited) 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 August 21, 2004 by bobheart Link to comment Share on other sites More sharing options...
bobheart Posted August 21, 2004 Author Share Posted August 21, 2004 Found the error . added the "",$folder = FileSelectFolder("Choose a directory to backup to","", @MyDocumentsDir)But it still does not copy files ? Link to comment Share on other sites More sharing options...
Developers Jos Posted August 21, 2004 Developers Share Posted August 21, 2004 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) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
bobheart Posted August 21, 2004 Author Share Posted August 21, 2004 Well what do you think it needs ? Link to comment Share on other sites More sharing options...
Developers Jos Posted August 21, 2004 Developers Share Posted August 21, 2004 Well what do you think it needs ? <{POST_SNAPBACK}>need to see the whole script to see what the issue could be.... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
bobheart Posted August 21, 2004 Author Share Posted August 21, 2004 $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 Link to comment Share on other sites More sharing options...
Lazycat Posted August 21, 2004 Share Posted August 21, 2004 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 Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
Developers Jos Posted August 21, 2004 Developers Share Posted August 21, 2004 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 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Lazycat Posted August 21, 2004 Share Posted August 21, 2004 Yes, this is should work, but better to add single file check, because result of FileOpenDialog is different in case single or multiple files. I just forgot this. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now