Sign in to follow this  
Followers 0
Quinch

Can't copy/move files

6 posts in this topic

'ello there, more-or-less long time AutoIt user {well, roughly since 3.1.0}, first time poster.

I'm experiencing a rather odd problem when trying to copy a file from a network location to my local machine. Copying it to the root folder of a drive, for example;

FileCopy($GMS&$list_name&@YEAR&$DAY&".lst", "G:\", 1) {{the variables are predefined or called by the function}}

...works like a charm. But whenever I try to copy them to an actual folder, for example;

FileCopy($GMS&$list_name&@YEAR&$DAY&".lst", "G:\Temp\", 1) {{or, in the latest version, flags 8 or 9}}

....I got nuffin. No error messages, no strange happenings, the file just doesn't copy. Any ideas what I might be doing wrong here?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

does Temp exist im guessing it does?

and betas tend to have problems not surprised if this is one

and if this error occurs im sure you can easily do a double filecopy and just make a _FileCopy Function that you can call and have it copy it to G:\ then copy it again to G:\Temp and idk but could the trailing backslash be the cause of it?

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yeah, it exists {tried with several other folders}. Mind you, I've tried the same script using 3.1.0 and 3.2.0.1 so I'm guessing it's a flaw in my script, rather than the app itself.

I've also done some experimentation and I've found something rather odd. Here's the function in whole;

Func DM_Sort($list_name, $header_line_offset, $dept_char_offset)
    FileCopy($GMS&$list_name&@YEAR&$DAY&".lst", "G:\NR_Lists\", 9)
    $active_list = FileOpen("G:\NR_Lists\"&$list_name&@YEAR&$DAY&".lst", 0)
    $active_list_path= "G:\NR_Lists\"&$list_name&@YEAR&$DAY&".lst"
    $list_length = _FileCountLines($active_list)

    For $page_header = $header_line_offset to $list_length step 53
        $header_read = FileReadLine($active_list, $page_header)
        $department_no = StringMid($header_read, $dept_char_offset, 2)
        $page_start = $page_header-($header_line_offset-1)
        $page_end = $page_header-$header_line_offset+53
        
        For $line_read = $page_start to $page_end step 1
            $content = FileReadLine($active_list, $line_read)
            FileWriteLine("G:\NR_Lists\Department-"&$department_no&".txt", $content)
        Next
    Next
    
    For $line_fill = 1 to 8 step 1
        $file_length = _FileCountLines("G:\NR_Lists\Department- "&$line_fill&".txt")
        While NOT _MathCheckDiv($file_length, 53) = 1
            FileWriteLine("G:\NR_Lists\Department- "&$line_fill&".txt", "")
        Wend
    Next

    For $line_fill = 11 to 15 step 1
        $file_length = _FileCountLines("G:\NR_Lists\Department- "&$line_fill&".txt")
        While NOT _MathCheckDiv($file_length, 53) = 1
            FileWriteLine("G:\NR_Lists\Department-"&$line_fill&".txt", "")
        Wend
    Next

    FileClose($active_list)
    FileDelete($active_list_path)
EndFunc

If I change the destination of the second line to something else, like G:\Temp, then the file will copy. But if I do that with the rest of the function {i.e. replace all G:\NR_Lists with G:\Temp}, nothing seems to happen.

{Edit: And no, tried it without the backslashes at the end of the destination, still no go}

Edited by Quinch

Share this post


Link to post
Share on other sites

everything looks clean to me, just for effects include the filename after G:\NR_Lists\name of file copying, it shouldnt be that you have to but its worth a shot, and im just curious as to what all your variables are cuz it could be an issue with the first parameter of file copy so do a messagebox and see if the first parameter is in fact what you want it to be

Share this post


Link to post
Share on other sites

Yep, looks like adding the filename to the destination fixed the copying problem.

As for the variables, I'm making {well, remaking} a script that will read a bunch of files and sort them by departments - list name is the name of the file, header line offset is on what line of the page the department's number is and the dept char offset is at what position of the line is the department number. Then it just reads the page line by line and dumps the content into the respective department's "sorted" files.

Share this post


Link to post
Share on other sites

o alright i was just curious as to the possibility of it being the first parameter, might want to get on those devs about the issue ;) you shouldnt have to include the filename afterwards

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  
Followers 0