Jump to content

[RESOLVED] Send to FileMove?


Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

$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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

$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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
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
 Share

×
×
  • Create New...