Friday, April 26, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 676  / 3 Years ago, sun, july 25, 2021, 1:24:13

I have a folder that has 200.000 images. I want to do the following:




  1. Move an X amount of images (50 images, 100 images, 200 images) from that folder to Y folder.

  2. Each Y folder can be a number (Folder 1, Folder 2, Folder 3...).

  3. The end result might look like this:



Folder 1 (Has X amount of images)
Folder 2 (Has X amount of images)
Folder 3 (Has X amount of images)
Folder 4 (Has X amount of images)


More From » bash

 Answers
6

Run the script in your image directory. Make sure that destination doesn't have any sub directories.




IMG=100 # Number of images to move
DES="." # Destination

I=$(find . -maxdepth 1 -mindepth 1 -type f | wc -l)
N=$(( (I / IMG) + (I % IMG) ))
eval mkdir "$DES"/Folder{01..$N}

for i in $(find "$DES" -maxdepth 1 -mindepth 1 -type d | sort); do
mv $(find . -maxdepth 1 -mindepth 1 -type f | sort | grep -m $IMG '.*') $i
done

[#34940] Monday, July 26, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brailloni

Total Points: 122
Total Questions: 108
Total Answers: 108

Location: North Korea
Member since Tue, Apr 4, 2023
1 Year ago
brailloni questions
Tue, Jun 21, 22, 21:51, 2 Years ago
Thu, Jul 29, 21, 05:25, 3 Years ago
Sat, Apr 2, 22, 17:32, 2 Years ago
Mon, Oct 31, 22, 21:39, 2 Years ago
;