nend

How to floor a number [SOLVED]

9 posts in this topic

#1 ·  Posted (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 by nend

Share this post


Link to post
Share on other sites



@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.

Share this post


Link to post
Share on other sites

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

2 people like this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@Melba23

Just perfect!

I never thought of that.

Thanks for your help.

Share this post


Link to post
Share on other sites

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

 

1 person likes this

Share this post


Link to post
Share on other sites
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... :P:P:P


ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Share this post


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

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