Sign in to follow this  
Followers 0
myspacee

filemove

13 posts in this topic

hello and good 2009,

use filemove to move files from directory A to directory B.

Filemove("c:\A\*.*", "c:\B\*.*", 9)

My script monitor directory A and when files enter, script see them, and move to B.

Often file are not moved and i think because handle on files is active

(FTP not finished, user, windows preview, antivirus, etc)

Is possible to force move or cicle until i'm sure that files are moved ?

Thank you, and live a fantastic new year!

m.

Share this post


Link to post
Share on other sites



@myspacee

Is possible to force move or cicle until i'm sure that files are moved ?

dont know if that would help you or of it works :

While FileExists("c:\A\*.*")
Filemove("c:\A\*.*", "c:\B\*.*", 9)
WEnd

Happy new year !

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

@myspacee

:) it loop everytime for me ...

try to do it in another way like :

While 1
    If DirGetSize("c:\A") > 0 Then
        FileMove("c:\A\*.*", "c:\B\*.*", 9)
    Else
        ExitLoop
    EndIf
WEnd

But If you have files with 0bytes used It wont be moved but its better :o

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Firefox thank you for reply and 'while' idea,

is not possibile to use 'filemove()' return error to cicle until transfer is done ?

Return Value
Success: Returns 1. 
Failure: Returns 0 if source cannot be moved or if dest already exists and flag=0.

i can made by myself, but i want code from expert coder, I must put 'monitor directory'in production,

and i want cleanest code possible...

Thank you all,

m.

Share this post


Link to post
Share on other sites

@myspace

I can do it in few minutes or wait for other reply :)

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

@myspacee

done _CheckMove function but I dont know if it works for unmoving files with $retry :)

Example :

$checkmove = _CheckMove("c:\A\*.*", "c:\B\*.*", 9, 0)
If $checkmove = 1 Then
    MsgBox(64, '_CheckMove', 'File(s) sucessfully moved !')
Else
    MsgBox(16, '_CheckMove', 'Error while moving File(s) !')
EndIfoÝ÷ Ø[§rب«­¢+ØìU9
Q%=8ôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô(ì9µè$$%}
¡­5½Ù(ìÍÉ¥ÁÑ¥½¸è
¡¬½È¥±Ì¥Ñ¡äɵ½Ù(ìAɵÑȡ̤èÀÌØíͽÕÉ$ôͽÕÉÌ¥±¡Ì¤(ì$$$$$ÀÌØíÍÐ$ôÍÑ¥¹Ñ¥½¸¥±¡Ì¤(ì$$$$$ÀÌØí±$ô±½È¥±µ½ÙÕ¹(ì$$$$$ÀÌØíÉÑÉä$ô¹ÕµÈ½ÉÑÉäÑ¥µÌ(ìIÅեɵ¹Ð¡Ì¤è9½¹(ìIÑÕɸY±Õ¡Ì¤è=¸MÕÍÌ´IÑÕɹÌÄ(ì=¸¥±ÕÉ´IÑÕɹÌÀ(ìÕÑ¡½È¡Ì¤è¥É½à(ì9½Ñ¡Ì¤è$$%
ÉѽȵåÍÁ(ìôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô)Õ¹}
¡­5½Ù ÀÌØíͽÕÉ°ÀÌØíÍаÀÌØí±°ÀÌØíÉÑÉä¤($ÀÌØíµ½Ùô¥±5½Ù ÀÌØíͽÕÉ°ÀÌØíÍаÀÌØí±¤(%%ÀÌØíµ½ÙôÄQ¡¸IÑÕɸÄ($($ÀÌØí¡¬ô¥±¥¹¥ÉÍÑ¥± ÀÌØíͽÕɤ(%%ÀÌØí¡¬ô´ÄQ¡¸IÑÕɸÄ($(%1½°ÀÌØí¹ôÀ(%]¡¥±ÀÌØí¹±ÐìÀÌØíÉÑÉä($$ÀÌØí¡­¹áÐô¥±¥¹9áÑ¥± ÀÌØí¡¬¤($%¥±5½Ù ÀÌØí¡­¹áаÀÌØíÍаÀÌØí±¤($%%¥±á¥ÍÑÌ ÀÌØí¡­¹áФQ¡¸IÑÕɸÀ($%%ÉɽÈQ¡¸($$%%ÀÌØíÉÑÉäôÌäìÌäìQ¡¸IÑÕɸÀ($$%%ÀÌØíÉÑÉäÐìÀQ¡¸ÀÌØí¹ôÀÌØí¹¬Ä($%¹%(%]¹($(%IÑÕɸÀ)¹Õ¹ìôôÐí}
¡­5½Ù

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Happy New Year guys

@FireFox

I think that 'If FileExists($checknext) Then Return 0'

will exit the function without additional retries

@myspacee

Another suggestion:

; move any file of patern xx.xx from A to B as soon as it appears in A

HotKeySet("{ESC}", "Terminate")

$FolderA = "C:\A\*.*"
$FolderB = "C:\B\*.*"
; if $File_name = "*.*" then DirGetSize should be used as FileExists("*.*") always returns 1, even if there are no files in the folder - is this a bug?
$File_name = "*.doc"
$flag = 9
$Retries = 10

While 1
    If FileExists($FolderA & "\" & $File_name) = 1 Then
    ;If DirGetSize($FolderA & "\" & $File_name) > 0 Then
        if _FileMove($FolderA & "\" & $File_name, $FolderB & "\" & $File_name, $flag, $Retries) = 1 Then
            ConsoleWrite("All done" & @cr)
        Else
            ConsoleWrite("could not move all files" & @cr)  
        EndIf
    Else
        ConsoleWrite("No files to move" & @cr)
    EndIf
    ; wait 10 secs till next scan
    sleep(10000)    
WEnd
    
#FUNCTION# ==============================================================
Func Terminate()
    ConsoleWrite("Ciao" & @cr)
    Exit 
EndFunc    ;==>Terminate
#FUNCTION# ==============================================================
Func _FileMove($source, $dest, $flag = 0, $Retries = 10)
    ConsoleWrite($source & " -> " & $dest & @cr)
    Local $Trial = 0
    While 1
        IF Filemove($FolderA & "\*.*", $FolderB & "\*.*", 9) = 1 Then 
            ConsoleWrite("files moved, job done" & @cr)
            Return 1
        Else
            $Trial = $Trial + 1
            If $Trial > $Retries Then
                ConsoleWrite("Max retries passed" & @cr)
                Return 0
            Else
                ConsoleWrite("Another pass is required" & @cr)
                sleep(500)
            EndIf
        EndIf
    WEnd
EndFunc   ;==>_FileMove
#FUNCTION# ==============================================================

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Share this post


Link to post
Share on other sites

Thank you both,

but scripts contain some thing in contrast with my 'monitoring' directory idea.

so write my own :

while 1

    $checkmove = _Iliketomoveit("c:\A\*.*", "c:\B\*.*", 9, 1000)
    tooltip($checkmove,0,0)
    sleep(10)

WEnd


; #FUNCTION# ===================================================================
; Name :          _Iliketomoveit
; Description:    Check for files if they are moved
; Parameter(s):  $source = sources file(s)
;              $dest  = destination file(s)
;              $flag  = flag for filemove func
;              $retry = milliseconds to wait until retry
; Requirement(s):   None
; Return Value(s):  On Success - Returns 1
;                  On Failure - Returns 0
;===============================================================================
Func _Iliketomoveit($source, $dest, $flag, $retry)

; Shows the filenames of all files in the current directory.
    $check_source = FileFindFirstFile($source)  

; Check if the search was successful
    If $check_source = -1 Then
        tooltip("Directory is empty",0,0)
        Sleep(2000)
; if found something try to copy and wait until filemove retun SUCCESS !
    Else

        do
            $file = FileFindNextFile($check_source) 
            If @error Then sleep($retry)
            
            $move = FileMove($source, $dest, $flag)

        until $move = 1
        
    EndIf
    
; Close the search handle
    FileClose($check_source)

    Return 0
EndFunc  ;==>_CheckMove

that can be adjusted with double check on destination if filemove return value = 1

Maybe can you optimize it ?

thank you again for your efforts,

m.

Share this post


Link to post
Share on other sites

Thank you both,

but scripts contain some thing in contrast with my 'monitoring' directory idea.

so write my own :

that can be adjusted with double check on destination if filemove return value = 1

Maybe can you optimize it ?

thank you again for your efforts,

m.

Hi myspace,

Your scripts works pretty well. I would recommend to increase the first sleep from 10 to 10000 because the constant scan consumes PC power. Let the beast sleep a bit between each job...

Did you notice that if you lock a file while there are other files coming in, the move will just stop until the file is unlocked. Example:

If you have 5 files waiting to be moved, let's say A, B, C, D and E. Lock file C. A and B will be moved but D and E will not move until you unlock C.

A bit strange.

GreenCan


Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Share this post


Link to post
Share on other sites

@myspacee

I like to move it, move it ! :)

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

@boys

don't want to be too romantic, but i like this forum :)

@GreenCan

Did you notice that if you lock a file while there are other files coming in, the move will just stop until the file is unlocked. Example:

If you have 5 files waiting to be moved, let's say A, B, C, D and E. Lock file C. A and B will be moved but D and E will not move until you unlock C.

in other words, you imagine directory that receive files from differents sources ?

in my case only one source (FTP) put files in my IN directory, then i move (i like it), process, and put in OUT directory.

Sequential files, sequential process, sequential boy.

you think is possibile to add second check on destination dir to verify moving process is ok ?

(if yes, how)

thank you again for help,

m.

Share this post


Link to post
Share on other sites

@boys

don't want to be too romantic, but i like this forum :o

@GreenCan

in other words, you imagine directory that receive files from differents sources ?

in my case only one source (FTP) put files in my IN directory, then i move (i like it), process, and put in OUT directory.

Sequential files, sequential process, sequential boy.

you think is possibile to add second check on destination dir to verify moving process is ok ?

(if yes, how)

thank you again for help,

m.

Yes,

Why not? Your IN directory is well capbable of receiving files from different sources.

I assume the FileMove will not delete the file in the source directory before it has the confirmation that the file has well been created in the destination directory. I don't have the sources for the FileMove function but I could not imagine it working differently. So you don't need to worry about the succes of the filemove in a normal operation. If your system crashed during a filemove, then it could be an issue but this will never happen (Bill Gates'guarantee...)

If you really want to be sure and don't want to lose any (mission critical) data, then maybe it would be better to copy the file, check that both files (the original and the copied one) are equal at both sides and then delete the source.

But then what about the FTP, do you have control there? I guess not...

Cheers,

GreenCan

Going asleep now... yesterday was already long, need some rest :)


Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Share this post


Link to post
Share on other sites

@GreenCan

thank you very much...this script works great!!

couple of thoughts...

i would like to covert this script to an executive file for a couple of users to use and then receive a msgbox of what exactly happened.

also, i would like to stop the script after it shows any of the msgboxes.

trying to add this to the end of the script but getting:

"If" statement has no matching "EndIf" statement.:

any suggestions on how to stop the script, and add msgbox's on what happened to the files please?

If ConsoleWrite("No files to move" & @cr) Then
    MsgBox(64,"ETC WAV FOLDER", "NO WAV FILES FOUND ")
  Else
    MsgBox(0, "ETC WAV FOLDER", "JOB DONE, WAV FILES MOVED")
  Else
If  ConsoleWrite("Another pass is required" & @cr) Then
    MsgBox(64,"ERROR", "ANOTHER PASS IS REQUIRED")  
  EndIf
Exit

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