Jump to content

get all files and make folder + copy every n files


Braese
 Share

Recommended Posts

Hi,

in example i have 6000 files in one folder, i will every 50 files make a new folder called 1 or folder one or whatever and copy first 50 files in this new folder. Then make next folder called two and copy next 50 files in it. This is theory. Possible with AutoIt i think, im not sure how can i get all files and then cut every 50 or a X Number of it into a new folder, perhaps any help? Thank you!

Link to comment
Share on other sites

$first = FileFindFirstFile("yourfolder\*.*")
If @Error Then Exit
Local $nb = 0, $fldrnb = 0, $fldr = "yourfolderoutput"
While 1
$sd = FileFindNextFile($first)
If @error then ExitLoop
FileCopy($sd, $fldr & $fldrnb)
$nb += 1
If $nb = 50 then
$fldrnb += 1
DirCreate($fldr & $fldrnb)
$nb = 0
EndIf
WEnd

Cheers, FireFox.

Link to comment
Share on other sites

Hi,

in example i have 6000 files in one folder, i will every 50 files make a new folder called 1 or folder one or whatever and copy first 50 files in this new folder. Then make next folder called two and copy next 50 files in it. This is theory. Possible with AutoIt i think, im not sure how can i get all files and then cut every 50 or a X Number of it into a new folder, perhaps any help? Thank you!

#include <File.au3>
$PATH = FileSelectFolder("SELECT","")
$FILE = _FileListToArray($PATH,"*",1)
$OUTPUT = "Output1"
DirCreate($OUTPUT)
Local $COUNT = 1, $FOLDER_INDEX = 1
ProgressOn("Copy",$PATH)
For $INDEX = 1 To $FILE[0]
    ProgressSet(Int($INDEX*100/$FILE[0]),$PATH & "\" & $FILE[$INDEX])
    FileCopy($PATH & "\" & $FILE[$INDEX],$OUTPUT)
    If $COUNT = 50 Then
        $COUNT = 0
        $FOLDER_INDEX += 1
        $OUTPUT = "Output" & $FOLDER_INDEX
        DirCreate($OUTPUT)
    EndIf
    $COUNT += 1
Next
ProgressOff()

When the words fail... music speaks.

Link to comment
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
 Share

  • Recently Browsing   0 members

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