obi Posted January 29, 2018 Report Posted January 29, 2018 Buna. Ma poate ajuta cineva cu urmatoarea problema. Am un folder cu vreo 150.000 de fisiere si vreau sa il impart in mai multe subfoldere. Un script, ceva ? Mersi. 1 Quote
M2G Posted January 29, 2018 Report Posted January 29, 2018 Parca esti la piata. "Vreau sa cumpar un porc. Cineva ceva?" Nu stiu cum poti sa te astepti la un raspuns cand pui o asa intrebare. Pe ce criterii vrei sa imparti fisierele in foldere? Dupa nume, extensie, dimensiune, foldere cu un anumit numar de fisiere? etc... Quote
obi Posted January 29, 2018 Author Report Posted January 29, 2018 Pai intrebarea era clara. Doar dupa numarul de fisiere, normal. Atat. 2 Quote
kznamst Posted January 29, 2018 Report Posted January 29, 2018 Chiar daca nu meriti, l-am facut mai mult pentru mine(imi place sa invat lucruri noi): #!/bin/bash subfolder_prefix="subfolder_" # subfolder prefix subfolders=6 #number of subfolders for i in `seq 1 $subfolders`; do mkdir "$subfolder_prefix$i" # create the subfolders done current_file=1 for i in $(find . -maxdepth 1 -type f -exec basename \{} \; | grep -v script_create_subfolders.sh); do # get all files from current directory. mv $i $subfolder_prefix$((current_file%subfolders))"/"$i current_file=$(( current_file + 1 )) done Quote
obi Posted January 29, 2018 Author Report Posted January 29, 2018 4 minutes ago, kznamst said: Chiar daca nu meriti, l-am facut mai mult pentru mine(imi place sa invat lucruri noi): #!/bin/bash subfolder_prefix="subfolder_" # subfolder prefix subfolders=6 #number of subfolders for i in `seq 1 $subfolders`; do mkdir "$subfolder_prefix$i" # create the subfolders done current_file=1 for i in $(find . -maxdepth 1 -type f -exec basename \{} \; | grep -v script_create_subfolders.sh); do # get all files from current directory. mv $i $subfolder_prefix$((current_file%subfolders))"/"$i current_file=$(( current_file + 1 )) done Mersi mult. Intre timp m-am descurcat dupa nr. de fisiere. i=0; for f in *; do d=dir_$(printf %03d $((i/1000+1))); mkdir -p $d; mv "$f" $d; let i++; done Quote