Jump to content
Sign in to follow this  
MSF

FileMove not moving files

Recommended Posts

MSF

My script will correctly create the test data and the test directories. However it does not move the files to the destination. I know I'm missing something really obvious here.

Here is my stand-alone example...

$num_files = InputBox( "Number Of Files", "How Many Files?", "1", "", -1, 1 )
If @error = 1 Then
    Exit
EndIf

;---------------------------------
;           debug statement(s)
;---------------------------------
ConsoleWrite( "Variable - $num_files = " & $num_files & @CRLF ) 

DirCreate( @ScriptDir & "\Process\" ) ; Destination
DirCreate( @ScriptDir & "\Failed\" ) ; Source

Local $move_files_to_here = @ScriptDir & "\Process\"
Local $move_files_from_here = @ScriptDir & "\Failed\"

;---------------------------------
;           debug statement(s)
;---------------------------------
ConsoleWrite( "Variable - $move_files_to_here = " & $move_files_to_here & @CRLF )
ConsoleWrite( "Variable - $move_files_from_here = " & $move_files_from_here & @CRLF )

;---------------------------------
; Test Data - Example: Copy and 
; Paste the first three 
; file names into the "Cleanup" 
; inputbox prompt
;---------------------------------

FileOpen( $move_files_from_here & "Test1.txt", 2 )
FileClose( $move_files_from_here & "Test1.txt" )
FIleOpen( $move_files_from_here & "Test2.txt", 2 )
FileClose( $move_files_from_here & "Test2.txt" )
FileOpen( $move_files_from_here & "Test3.txt", 2 )
FIleClose( $move_files_from_here & "Test3.txt" )
FileOpen( $move_files_from_here & "Test4.txt", 2 )
FIleClose( $move_files_from_here & "Test4.txt" )
FileOpen( $move_files_from_here & "Test5.txt", 2 )
FIleClose( $move_files_from_here & "Test5.txt" )
FileOpen( $move_files_from_here & "Test6.txt", 2 )
FIleClose( $move_files_from_here & "Test6.txt" )

For $ctr = 0 To $num_files -1
   
    Local $file_name = InputBox( "Cleanup", "Enter File Name " & $ctr +1, "", "", -1, 1 )
    If @error = 1 Then
        Exit
    EndIf
    
    ;---------------------------------
    ;           debug statement(s)
    ;---------------------------------
    ConsoleWrite("Variable - $file_name = " & $file_name & @CRLF )  
        
    FileMove( $move_files_from_here  & $file_name, $move_files_to_here & $file_name, 9 )
    
    ;---------------------------------
    ;           debug statement(s)
    ;---------------------------------
    ConsoleWrite("Statement - Moved From: " & $move_files_from_here & $file_name & @CRLF )
    ConsoleWrite("Statement - Moved To: " & $move_files_to_here & $file_name & @CRLF )
    
Next

Any help would be much appreciated!

Thanks!

-MSF

Edited by MSF

Share this post


Link to post
Share on other sites
MrCreatoR

Now click on the FileOpen/FileClose function in your code area (yeap, it seems that this is new functionality for the autoit tags on forum :D ), and read how to use it.

The file is not closed, it can not be moved (why to open it in the first place - it's another mistery for me :D ).

Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
MSF

Now click on the FileOpen/FileClose function in your code area (yeap, it seems that this is new functionality for the autoit tags on forum :D ), and read how to use it.

The file is not closed, it can not be moved (why to open it in the first place - it's another mistery for me :D ).

Oh I get it... Thanks!

This:

$file = FileWrite($move_files_from_here & "Test1.txt", 0)
$file = FileWrite($move_files_from_here & "Test2.txt", 0)
$file = FileWrite($move_files_from_here & "Test3.txt", 0)
$file = FileWrite($move_files_from_here & "Test4.txt", 0)
$file = FileWrite($move_files_from_here & "Test5.txt", 0)
$file = FileWrite($move_files_from_here & "Test6.txt", 0)

Share this post


Link to post
Share on other sites
Inverted

W00T !

I really like the new help-linking !

Althought the fonts are too small in that help section ...

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  

×