Jump to content

Recommended Posts

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
Posted

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

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Posted

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

 

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

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...