nend Posted February 25, 2017 Share Posted February 25, 2017 (edited) Hoi! Is there a sollution to this problem. I have a lot of files numbered from 0 till 1000000 I want to copy them to a new directory structure. so 0 'till 9999 get in a dir called 0 1000 'till 1999 gets in a dir called 1000 and so on. How can I floor a number 1956 to 1000 and that for al the numbers. I don't have a example code because I don't no where to start to floor this number so that the code can create this directory. Any ideas? Edited February 25, 2017 by nend Link to comment Share on other sites More sharing options...
JohnOne Posted February 25, 2017 Share Posted February 25, 2017 (edited) Surely a simple switch case would suffice. Edited February 25, 2017 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nend Posted February 25, 2017 Author Share Posted February 25, 2017 @JohnOne Mabey I'm wrong but if you want a 1000000 files sort in a directory from max 10000 each you have a switch case from 100 pieces. I do think there had to be a better way. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 25, 2017 Moderators Share Posted February 25, 2017 nend, Just use some very basic maths: $iCurrFolderNum = -1 For $i = 0 To 3000 Step 100 ; Just for testing $iMils = Int($i / 1000) If $iMils <> $iCurrFolderNum Then $iCurrFolderNum = $iMils ConsoleWrite("Creating folder: FolderNum_" & $iCurrFolderNum * 1000 & @CRLF) ; You use DirCreate here EndIf ConsoleWrite("Copying file " & $i & " into folder " & $iCurrFolderNum * 1000 & @CRLF) ; And use FileMove/Copy here Next M23 nend and 232showtime 2 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted February 25, 2017 Share Posted February 25, 2017 Post a simple example script which demonstrates your issue. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nend Posted February 25, 2017 Author Share Posted February 25, 2017 @Melba23 Just perfect! I never thought of that. Thanks for your help. Link to comment Share on other sites More sharing options...
Malkey Posted February 25, 2017 Share Posted February 25, 2017 You mentioned you want the 1,000,000 files divided up in both 10,000 lots of files and 1000 lots of files. I assume you want each directory that contain 10,000 files to have 10 subdirectories each containing 1,000 files. For $i = 0 To 1000000 ;Step 100 ConsoleWrite("c:\" & Floor($i / 10000) * 10000 & "\" & Floor($i / 1000) * 1000 & "\" & $i & ".ext" & @CRLF) Next nend 1 Link to comment Share on other sites More sharing options...
232showtime Posted February 25, 2017 Share Posted February 25, 2017 17 minutes ago, Melba23 said: nend, Just use some very basic maths: $iCurrFolderNum = -1 For $i = 0 To 3000 Step 100 ; Just for testing $iMils = Int($i / 1000) If $iMils <> $iCurrFolderNum Then $iCurrFolderNum = $iMils ConsoleWrite("Creating folder: FolderNum_" & $iCurrFolderNum * 1000 & @CRLF) ; You use DirCreate here EndIf ConsoleWrite("Copying file " & $i & " into folder " & $iCurrFolderNum * 1000 & @CRLF) ; And use FileMove/Copy here Next M23 I'm your no.1 fan... 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...
nend Posted February 25, 2017 Author Share Posted February 25, 2017 16 minutes ago, Malkey said: You mentioned you want the 1,000,000 files divided up in both 10,000 lots of files and 1000 lots of files. I assume you want each directory that contain 10,000 files to have 10 subdirectories each containing 1,000 files. For $i = 0 To 1000000 ;Step 100 ConsoleWrite("c:\" & Floor($i / 10000) * 10000 & "\" & Floor($i / 1000) * 1000 & "\" & $i & ".ext" & @CRLF) Next This one works also perfect. Thanks all for helping me. 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