Skip to content

move several files in image directories

As you know magento store images in pub media folder
I import lots of files (millions), thousands at once and I thought it is a good idea to split those millions files in at least thousands folders
So my namefiles.jpg are barcode
i created a batch in windows to split those files into subdirectories based on the name files

like so

move /Y ?????????0000p.jpg p
move /Y ?????????1000p.jpg p1
move /Y ?????????2000p.jpg p2
move /Y ?????????3000p.jpg p3
move /Y ?????????4000p.jpg p4
move /Y ?????????5000p.jpg p5
move /Y ?????????6000p.jpg p6
move /Y ?????????7000p.jpg p7
move /Y ?????????8000p.jpg p8
move /Y ?????????9000p.jpg p9
move /Y ?????????0100p.jpg p1
move /Y ?????????1100p.jpg p11
move /Y ?????????2100p.jpg p12
... 

and so on for all 0000 -> 9999 possibilities
Since number are random the files are more or less splitted equally

In windows I created a .bat with all 10.000rows to move files, then I zip everything, upload and unzip in the main server. Anyone knows a way to do it in linux?