Help splitting lare number of files intosmaller directories

Si.

Si.

Soldato
Joined
22 Oct 2002
Posts
2,673
Location
Melbourne, Aus
Hi all.

I have a folder with 500K+ files in it but the script I'm using to import them into SQL is crashing.. is there an easy way to split these files into separate folders (I don't care what the names are) as I know it works with upto 100k files.
 
This isn't much help on a Linux box but I'll post it anyway as you may have access to the files from a Windows box, I done something similar (moving .jpgs) using a batch file in Windows:
Code:
@ECHO OFF

SETLOCAL ENABLEDELAYEDEXPANSION

:: Config parameters
SET groupsize=200
:: initial counter, everytime counter is 1, we create new folder
SET n=1
:: folder counter
SET nf=0

FOR %%f IN (*.jpg) DO (
  :: if counter is 1, create new folder
  IF !n!==1 (
    SET /A nf+=1
    MD folder!nf!
  )

  :: move file into folder
  MOVE /Y "%%f" folder!nf!

  :: reset counter if larger than group size
  IF !n!==!groupsize! (
    SET n=1
  ) ELSE (
    SET /A n+=1
  )
)

ENDLOCAL

PAUSE
 
Last edited:
Back
Top Bottom