Fraser Posted June 8, 2012 Share Posted June 8, 2012 Hi, This is a hard one to explain, but here i go! I have had a request to create an app that will Robocopy a folder structure with its permissions (i have this part sorted) to over 200 folders! I wanted to try and automate this and have come across the _FileListToArray function: $FileList = _FileListToArray("C:\Users\jblogg\Desktop\TEST Folder\", "*", 2) The above will create an array of folder names like this: RowCol0 [0] 0000 - Test Folder [1] 0564 - Test Folder [2] 8659 - Test Folder [3] Ted's Folder I've been asked to make it so it will only copy the folder structure to the folders with naming convention of '0000 - Test Folder', however i can't think how to do this. Any help would be much appreciated! Regards, Jamie Link to comment Share on other sites More sharing options...
water Posted June 8, 2012 Share Posted June 8, 2012 Something like this? ;$sFoldername = "0000 - Test Folder" $sFoldername = "Ted's Folder" $iNumber = Number(StringLeft($sFolderName, 4)) $sText = StringMid($sFolderName, 5) If IsNumber($iNumber) And $sText = " - Test Folder" Then MsgBox(0, "", "Process Folder") Else MsgBox(0, "", "Don't Process Folder") EndIf My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Mechaflash Posted June 8, 2012 Share Posted June 8, 2012 (edited) Or plug in the naming convention into _FileListToArray() function $enum = "C:UsersjbloggDesktopTEST Folder" $out = "C:UsersjbloggDesktopTEST OUTPUT FOLDER" $FileList = _FileListToArray($enum, "0000 - Test Folder", 2) ; get only folders with the quoted string _ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index For $folder in $FileList ; Loop over folders found. DirMove($enum & $folder, $out & $folder, 1) ; Argument 3 = 1 = overwrite Next Edited June 8, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
water Posted June 8, 2012 Share Posted June 8, 2012 I understand the OP that he wants to process all folders starting with 4 digits and the text " - Test Folder" at the end. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Fraser Posted June 8, 2012 Author Share Posted June 8, 2012 Hi, Thank you for the speedy responses. The department use 'Project number - Project name' as the folder structure i.e. '9564 - The Big House' or '7538 - Red Farm'. So i have tweeked the FileListToArray so that it will only show the folders with the format, however I don't know what the best way is to use the array to copy the folder in to the folders listed! $FileList = _FileListToArray("C:Usersjfras1scDesktopTEST Folder", "* - *", 2) Thanks and regards, Fraser Link to comment Share on other sites More sharing options...
Mechaflash Posted June 8, 2012 Share Posted June 8, 2012 (edited) The department use 'Project number - Project name' as the folder structure i.e. '9564 - The Big House' or '7538 - Red Farm'.I don't know what the best way is to use the array to copy the folder in to the folders listed!are the folders in the array being copied or moved?EDIT: Contrary to the title, your quoted post states "copy the folder in to the folders listed"On another note... when you say "copy the folder in to the folders listed", is there another folder that's being copied/moved into each folder in the array, or is each folder in the array being copied/moved to another folder? Edited June 8, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
Fraser Posted June 8, 2012 Author Share Posted June 8, 2012 Hi, Thank you ver much for your help! The file are being copied with the security so i have tweek you code a little. #include <File.au3> #include <Array.au3> $enum = "C:UsersJbloggDesktopTEST Folder" $source = "C:UsersjbloggDesktopTEST FolderSource Folder01 File" $FileList = _FileListToArray("C:Usersjfras1scDesktopTEST Folder", "* - *", 2) ; get only folders with the quoted string _ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index For $folder in $FileList ; Loop over folders found. DirCreate($enum & $folder & "01 File") Sleep(1000) RunWait('robocopy /e /copy:S "' & $source & '" "' & $enum & $folder & '01 File"') Next Agian Thank you very much for the help! Kind Regards, Fraser Link to comment Share on other sites More sharing options...
Mechaflash Posted June 8, 2012 Share Posted June 8, 2012 I don't believe the Sleep() is necessary as the function DirCreate() waits to be completed before moving onto the next command. Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
Fraser Posted June 8, 2012 Author Share Posted June 8, 2012 Just a procuration as the works network is crap! Link to comment Share on other sites More sharing options...
Mechaflash Posted June 8, 2012 Share Posted June 8, 2012 The DirCreate() function checks to make sure it was created at the destination. That's why it can return a 0 or 1 based on whether or not it really did get created. Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” 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