Jump to content
Sign in to follow this  
johnmcloud

[RESOLVED] Send to FileMove?

Recommended Posts

johnmcloud

The FileMove command is simple

FileMove("C:Test", "D:Test")

But if i want to use it with different dir, for example put it in "SendTo" dir? Like a script .bat. So the first dir change, and the second is always the same. It's possible?

Thanks

Edited by johnmcloud

Share this post


Link to post
Share on other sites
johnmcloud

I know the fuction reference. I'll do an example:

Take this .bat:

Dir %1 /oe > c:windowstempList.txt

Save it in SendoTo folder ( %APPDATA%MicrosoftWindowsSendTo )

If right click on a folder -- Send To -- Bat, i have a list of that directory.

I want do the same with autoit, with the function FileMove

Right click on a folder -- Send To -- Autoit .exe

result: Move the folder to destination directory ( the destination is always the same )

I hope I was clear,

Thanks for support

Share this post


Link to post
Share on other sites
magodiez

you can do it with a batch:

move "%1*.*" D:Test

or in Autoit:

$destination = "D:Test"
If($CmdLine[0] > 0) Then
  FileMove ( $CmdLine[1], $destination)
Else
  MsgBox(0x10,"Error!",$CmdLine[0] & " arguments passed!")
EndIf

Note: This only would move the files in the folder, but no sub-folders

Edited by magodiez

Share this post


Link to post
Share on other sites
guinness

Thanks JohnOne.

johnmcloud,

At the top of your script add something like this >>

If $CmdLine[0] Then
    For $A = 1 To $CmdLine[0]
        If StringInStr(FileGetAttrib($CmdLine[$A]), "D") Then ; Is a Folder/Directory
            DirMove($CmdLine[$A], "<DESTINATIONPATH>")
        Else ; Otherwise it must be a file.
            FileMove($CmdLine[$A], "<DESTINATIONPATH>")
        EndIf       
    Next
EndIf

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
johnmcloud

johnmcloud,

At the top of your script add something like this >>

Thanks guinness,

You script work only with single file, not with directory ( don't doing nothing )

And if can explain the first part of the script?

I don't understand this part:

If $CmdLine[0] Then
    For $A = 1 To $CmdLine[0]

I am here also to learn, thanks for support :D

Edited by johnmcloud

Share this post


Link to post
Share on other sites
magodiez

$CmdLine[0] is number of parameters (for more info http://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine)

to work with Directories add the flag 1 to overwrite

DirMove($CmdLine[$A], $destination,1)

and you can also add the flag 8 for files, in case the destination folder is not created

FileMove($CmdLine[$A], $destination,8)

$destination = "D:\Test"
If $CmdLine[0] Then
    For $A = 1 To $CmdLine[0]
  If StringInStr(FileGetAttrib($CmdLine[$A]), "D") Then ; Is a Folder/Directory
            DirMove($CmdLine[$A], $destination,1)
        Else ; Otherwise it must be a file.
            FileMove($CmdLine[$A], $destination,8)
        EndIf
    Next
EndIf

Share this post


Link to post
Share on other sites
somdcomputerguy

I'm not sure why this doesn't work with directories, but for the 'first part' thing, see this in the Help file:

Command Line Parameters

For...Next


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
guinness

Seems people have answered already. When I said 'like this' I should have mentioned that please read the additional remarks in the Help file for the functions DirMove & FIleMove.

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
johnmcloud

$CmdLine[0] is number of parameters (for more info http://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine)

to work with Directories add the flag 1 to overwrite

DirMove($CmdLine[$A], $destination,1)

and you can also add the flag 8 for files, in case the destination folder is not created

FileMove($CmdLine[$A], $destination,8)

$destination = "D:Test"
If $CmdLine[0] Then
    For $A = 1 To $CmdLine[0]
  If StringInStr(FileGetAttrib($CmdLine[$A]), "D") Then ; Is a Folder/Directory
            DirMove($CmdLine[$A], $destination,1)
        Else ; Otherwise it must be a file.
            FileMove($CmdLine[$A], $destination,8)
        EndIf
    Next
EndIf

Thanks man, work, but i need another example for learn better the function.

I have now made this script:

$source = "C:"
$dest = "C:Test.txt"
RunWait(@ComSpec & " " & "/k" & " "& "dir >" & " " &$dest& " " &$source& "&& Echo. && Echo finished")

Working fine, create a file in C: with the directory of C:

Now i want to apply your scipt into this, but not work, What i'm doing wrong?

$dest = "C:Test.txt"
If $CmdLine[0] Then
    For $A = 1 To $CmdLine[0]
  If StringInStr(FileGetAttrib($CmdLine[$A]), "D") Then ; Is a Folder/Directory
  RunWait(@ComSpec & " " & "/k" & " "& "dir >" & " " &$dest& " " &$CmdLine[$A]& "&& Echo. && Echo finished")
        EndIf
    Next
EndIf
Edited by johnmcloud

Share this post


Link to post
Share on other sites
magodiez

that code works fine in my computer... Do you get any error???

Share this post


Link to post
Share on other sites
johnmcloud

that code works fine in my computer... Do you get any error???

Now Work, i don't know what was the problem.

I'll post again:

$dest = "C:TestFile.txt"
If $CmdLine[0] Then
    For $A = 1 To $CmdLine[0]
  If StringInStr(FileGetAttrib($CmdLine[$A]), "D") Then ; Is a Folder/Directory
  RunWait(@ComSpec & " " & "/c" & " "& "dir >" & " " & '"'&$dest& '"' & " " & '"' &$CmdLine[$A]& '"' & " " & "&& Echo. && Echo finished", "", @SW_HIDE)
        EndIf
    Next
EndIf

N.B Why i can't post like Autoit code?. I click OK but nothing happens, maybe is a browser problem...

Thanks guys for support, in particularly magodiez and guinness.

Edited by johnmcloud

Share this post


Link to post
Share on other sites
guinness

Thanks guys for support, in particularly magodiez and guinness.

You're welcome but I only did about 5% of the work.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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  

  • Similar Content

    • MFrancisca
      By MFrancisca
      Hello everyone,
      I'm trying to make a script that renames a file. I'm using FileMove but I'm really confused.
      The name change is on the EXTENSION, not on the file name itself. I need to change it from ".exe_" to "exe".
      FileMove is returning a 0 value and the file is clearly not renamed. Here is the relevant code.
      For $index = 1 to (UBound($file_array) - 1) $new_file_name = StringTrimRight($file_array[$index], 1) FileMove($dir & "\" & $file_array[$index], $dir & "\" & $new_file_name) Next  some context notes: 
      $file_array is the output of _FileListtoArray, and it has the correct values.  $dir is known, and the script is detecting it without problem I've checked that the script is finding the correct files, and that TrimRight is working. All variables have the correct values. I've checked the file attributes, the are set to "A". Are those the correct attributes? I've tried setting the flag of FileMove to 1, 8 and 9 with the same results This was working fine 2 weeks ago when I did the last run,  and I've made no changes.  (I don't know why the syntax highlighting is messed, quotes are paired correctly) 
       
      I know that the help file says that FileMove will not succeed if the destination already exist... my question is, does FileMove count extensions? 
      Thank you!  
    • 232showtime
      By 232showtime
      hi im stuck with this I want to transfer the correct file in the existing folder
      #include <File.au3> #include <AutoItConstants.au3> #include <Array.au3> $Read = "C:\New folder (3)" $FLFiles1 = _FileListToArrayRec($Read, "*.xlsx", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_SORT, $FLTAR_NOPATH) _ArrayDisplay($FLFiles1) For $i = 0 To UBound($FLFiles1) - 1 $STR = StringTrimRight($FLFiles1[$i], 5) ConsoleWrite($STR & @CRLF) $dirS = DirGetSize($Read & "\" & $STR) If $dirS = -1 Then MsgBox(16, $STR, $dirS) Else FileMove($Read, $Read & "\" & $STR & "\" & $STR & ".xlsx") EndIf next I have 3 folders under "C:\New folder (3)" and I have 5 excel files:
      folders:
      C:\New folder (3)\1
      C:\New folder (3)\3
      C:\New folder (3)\5
      excel files:
      1.xlsx (value of column A are all 1)
      2.xlsx (value of column A are all 2)
      3.xlsx (value of column A are all 3)
      4.xlsx (value of column A are all 4)
      5.xlsx (value of column A are all 5)
       
       I run the above script and those excel file 1, 3, 5 was transfered in the 1, 3, and 5 folders but the value of transfered file in Column A are  different and file no. 4 and 5 still remains in the folder "C:\New folder (3)".... ???
      whats wrong with the script???
       
       
    • copyleft
      By copyleft
      I am trying to create a script to clean up users' desktops by moving all desktop folders and files (except the two hidden "desktop.ini" files and a MyDesktop.lnk shortcut) to a different folder. The script below will move files but not folders. The other issue with the script is that it doesn't seem to execute from a location other than the user's desktop. I would appreciate any suggestions.
      #include <File.au3> MsgBox(64, "Desktop", "Cleaning up Desktop. This box will close in 4 seconds.", 4) $Files = _FileListToArray(@DesktopDir,"*",1) For $Index = 1 To $Files[0] If StringRight($Files[$Index],4) <> ".ini, MyDesktop.lnk" Then FileMove($Files[$Index],'F:\HOME\Desktop') EndIf Next  
    • XinYoung
      By XinYoung
      Hello again,
      I'm trying to use the FileMove function to rename a bunch of text files.
      Some of the files have "_1" at the end of their name, for example, "File123_1.txt". I want to remove the "_1" so it would become "File123.txt".
      What I currently have...
              FileMove($sSource & "\*_1.txt", $sDestination & "\*.txt")
      But since I'm using a wildcard, it doesn't appear to be working. I think it's just replacing .txt with .txt. Am I going about this the wrong way? How can I use wildcards and still accomplish this?
      Any help is greatly appreciated ^__^
    • Simpel
      By Simpel
      Hi,
      while debugging sometimes I need the au3 stripped script with /mo parameter, so that error lines in the error message match the script. Things I use often I put inside sendto folder (shell:sendto) so I can push my file to this with right click fast. A long time I had problems with some of my scripts stripping this way because the some paths to my script included spaces (you should not do that). But here’s my solution fixing that problem:
      Local $sPathToAU3Stripper = "" ; fill in the path here Local $sPath If $CmdLineRaw = "" Then ; you didn't do it with sendto $sPath = FileOpenDialog("Which file you want to AU3-strip?", "","AU3 (*.au3)", 3) If @error Then MsgBox(0, 'Error FileOpenDialog:', @error) Exit EndIf Else $sPath = $CMDLINE[1] EndIf Local $sPath_quoted = '"' & $sPath & '"' ShellExecuteWait($sPathToAU3Stripper, $sPath_quoted & ' /mo', "", "", @SW_HIDE) I hope someone will find it useful.
      Regards, Conrad
×