sumandevadiga Posted May 16, 2017 Share Posted May 16, 2017 (edited) Hello Trying to add below code in my main script but this is not functioning can you advise what else i need to do? Dim fn As String Const myDir As String = "C:\AR\" '<- alter here Const newFolder As String = "C:\AR1\" '<- alter here fn = Dir(myDir & "AR_*.xlsm") Do While fn <> "" FileCopy myDir & fn, newFolder & Replace(fn, "AR", "AI") fn = Dir Loop Edited May 16, 2017 by sumandevadiga I did some error while pasting code Link to comment Share on other sites More sharing options...
MattHiggs Posted May 16, 2017 Share Posted May 16, 2017 So are you requesting help in regards to how to get an autoit script to work or a VB script? If it is the latter, I am afraid you have the wrong forums... However, if it is the former, please let me know, and I would be glad to help. Link to comment Share on other sites More sharing options...
Subz Posted May 16, 2017 Share Posted May 16, 2017 In AutoIt it would be: #include <FileConstants.au3> Local $sSource = "C:\AR" Local $sTarget = "C:\AR1" DirCopy($sSource, $sTarget, $FC_OVERWRITE) Link to comment Share on other sites More sharing options...
spudw2k Posted May 16, 2017 Share Posted May 16, 2017 He also wants to rename the destination files. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
spudw2k Posted May 16, 2017 Share Posted May 16, 2017 (edited) One way...line by line conversion from vbscript to autoit #include <File.au3> #include <FileConstants.au3> ;Dim fn As String Local $fn ;Const myDir As String = "C:\AR\" '<- alter here Const $myDir = "C:\AR\" ;Const newFolder As String = "C:\AR1\" '<- alter here Const $newFolder = "C:\AR1\" ;fn = Dir(myDir & "AR_*.xlsm") $fn = _FileListToArrayRec($myDir, "AR_*.xlsm", $FLTAR_FILES, $FLTAR_RECUR) ;Do While fn <> "" For $sFile in $fn ; FileCopy myDir & fn, newFolder & Replace(fn, "AR", "AI") FileCopy($myDir & $sFile, $newFolder & StringReplace($sFile, "AR", "AI"), $FC_OVERWRITE + $FC_CREATEPATH) ; fn = Dir ;Loop Next Edited May 16, 2017 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
spudw2k Posted May 16, 2017 Share Posted May 16, 2017 4 hours ago, MattHiggs said: So are you requesting help in regards to how to get an autoit script to work or a VB script? Good point...sorry we jumped ahead Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
MattHiggs Posted May 16, 2017 Share Posted May 16, 2017 Just now, spudw2k said: Good point...sorry we jumped ahead No worries man. From the syntax that was posted, it looked more like Visual basic than Autoit, which is what prompted the question. However, I don't have....well....any.....experience with Visual basic, so I wouldn't have been able to help if that were the case. But at least he has the answer now if he needed help with autoit Link to comment Share on other sites More sharing options...
KickStarter15 Posted May 17, 2017 Share Posted May 17, 2017 @sumandevadiga, You need to put the filename to "true" to work with your code "objFSO.CopyFile" will not work with wildcards. Except you have it this way: Dim fso As Object Dim FromPath As String Dim ToPath As String Dim objFSO, objFolder, strFile FromPath = "C:\AR\" ToPath = "C:\AR1\" If fso.FolderExists(FromPath) = False Then MsgBox "File doesn't exist. Not found!" Exit Sub End If For Each strFile In objFolder.Files If objFSO.GetExtensionName(strFile.Name) = "xlsm" Then objFSO.CopyFile strFile.Path, ToPath End If Next Not tested, from my old VBscript. Hope you can get some idea and hope it helps. If you want to use AutoIt, then you must follow Subz and spudw2k's posted above. Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
sumandevadiga Posted May 23, 2017 Author Share Posted May 23, 2017 Hello Kickstarter15, Sorry for the delay reply, this is in VB script not Autoit, however i have tried your suggested code, this is not giving any output or result. Dim fso As Object Dim FromPath As String Dim ToPath As String Dim objFSO, objFolder, strFile FromPath = "C:\AR\" ToPath = "C:\AR1\" If fso.FolderExists(FromPath) = False Then MsgBox "File doesn't exist. Not found!" Exit Sub End If For Each strFile In objFolder.Files If objFSO.GetExtensionName(strFile.Name) = "xlsm" Then objFSO.CopyFile strFile.Path, ToPath End If Next Link to comment Share on other sites More sharing options...
232showtime Posted May 23, 2017 Share Posted May 23, 2017 this is autoit forum not vb forum, but if you want to copy files from 1loc to another loc you can do like this ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon. Link to comment Share on other sites More sharing options...
KickStarter15 Posted May 24, 2017 Share Posted May 24, 2017 @sumandevadiga, Have you tried changing it? the logic is already in that script. Anyway, I have it this way: Set objFSO = CreateObject("Scripting.FileSystemObject") FromPath = "C:\AR\" ToPath = "C:\AR1\" Set objFolder = objFSO.GetFolder(FromPath) Set colFiles = objFolder.Files For Each objFile In colFiles strFileName = objFile.Name If objFSO.GetExtensionName(strFileName) = "xlsm" Then objFSO.CopyFile FromPath & objFile.Name, ToPath End If Next NOTE: As what 232Showtime stated above, this is not a vbscript forum. So better to ask what does the forum is for. Now, for AutoIt code this is how it was done: #include <FileConstants.au3> FromPath = "C:\AR\" ToPath = "C:\AR1\" FileCopy(FromPath & "*.xlsm", ToPath, $FC_OVERWRITE + $FC_CREATEPATH) KS15 Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
sumandevadiga Posted May 25, 2017 Author Share Posted May 25, 2017 Hello Kickstarter15, Thank you very much for your support. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now