Sign in to follow this  
Followers 0
Braese

get all files and make folder + copy every n files

4 posts in this topic

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!

Share this post


Link to post
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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thx Andreik and Firefox!

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
Sign in to follow this  
Followers 0