johnmcloud Posted July 4, 2012 Posted July 4, 2012 (edited) Hi guys, Maybe it's a stupid error, but really I can not find a solution. I have a txt with path of files, example: C:\Documents and Settings\Windows Xp\Desktop\autoit-v3-setup.exe C:\Documents and Settings\Windows Xp\Desktop\File.au3 C:\Documents and Settings\Windows Xp\Desktop\RecFileListToArray.au3 C:\Documents and Settings\Windows Xp\Desktop\SciTE4AutoIt3.exe The last line is empty. Now i want to copy the file and i have make this: $Log = FileRead(@WorkingDir & "\Final.txt") $aArray = StringSplit($Log, @LF) For $i = 1 To $aArray[0] -1 ; - 1 remove last empty line ;~ MsgBox(0,0, $aArray[$i]) FileCopy($aArray[$i], "C:\") Next With MsgBox or ConsoleWrite i see the full path, but the FileCopy not work. Some advice? Thanks Edited July 4, 2012 by johnmcloud
hannes08 Posted July 4, 2012 Posted July 4, 2012 Hello johnmcloud, check the returncode of the FileCopy function. Maybe you're missing the right to copy files directly to C:? Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
johnmcloud Posted July 4, 2012 Author Posted July 4, 2012 (edited) Hi, No, it's not a problem of right, check this: $Log = FileRead(@WorkingDir & "Final.txt") $aArray = StringSplit($Log, @LF) For $i = 1 To $aArray[0] -1 MsgBox(0,0, $aArray[$i]) FileCopy($aArray[$i], @DesktopDir & "Test", 8) Next I can copy files to my desktop? ReturnCode is 0, so failure Edited July 4, 2012 by johnmcloud
hannes08 Posted July 4, 2012 Posted July 4, 2012 Which OS are you running? Try adding a "#RequireAdmin" on top of your script. As far as I know, Vista and later require administrative rights to write directly to the C: drive Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Exit Posted July 4, 2012 Posted July 4, 2012 There are blanks in the filenames. Enclose them in Hyphens. FileCopy('"' & $aArray[$i] & '"', "C:") App: Au3toCmd UDF: _SingleScript()
johnmcloud Posted July 4, 2012 Author Posted July 4, 2012 (edited) @hanness08 Check the first post and the path in the code It's XP @forumer100 Not work: #RequireAdmin ; hanness08 $Log = FileRead(@WorkingDir & "Final.txt") $aArray = StringSplit($Log, @LF) For $i = 1 To $aArray[0] -1 ; - 1 remove last empty line ConsoleWrite($aArray[$i]) FileCopy("C:Documents and SettingsWindows XpDesktopautoit-v3-setup.exe", @WorkingDir & "Test") ; This Work, also without the #RequireAdmin FileCopy('"' & $aArray[$i] & '"', @WorkingDir & "Test") ; This not, WTF! Next Please someone test it Edited July 4, 2012 by johnmcloud
UEZ Posted July 4, 2012 Posted July 4, 2012 Can you try this one here? $aArray = StringSplit($Log, @CRLF) Is it working? Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
johnmcloud Posted July 4, 2012 Author Posted July 4, 2012 No UEZ, not work ( why you changed your avatar? Almost did not recognize you )
UEZ Posted July 4, 2012 Posted July 4, 2012 (edited) I assume that StringSplit will leave some characters (CR) in the filename which will cause the problem. I was bored looking to Dali everytime. Br, UEZ Edited July 4, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
johnmcloud Posted July 4, 2012 Author Posted July 4, 2012 (edited) Mmm you have right:#include <File.au3> $Log = FileRead(@WorkingDir & "Final.txt") $aArray = StringSplit($Log, @CR) _FileWriteFromArray(@WorkingDir & "Test.txt",$aArray)This is the output: #include <File.au3> $Log = FileRead(@WorkingDir & "Final.txt") $aArray = StringSplit($Log, @CRLF) _FileWriteFromArray(@WorkingDir & "Test.txt",$aArray)This is the output:Suggestion? Edited July 4, 2012 by johnmcloud
johnmcloud Posted July 4, 2012 Author Posted July 4, 2012 Solved, now the FileCopy work: StringSplit($Log, @CR & @LF) Thanks to all
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