Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a folder with 80.000 files on my iMac G5 running Ubuntu 12.04.1 and I can't even open it with Nautilus because it freezes.

I can do ls -a in Terminal and it shows me everything.

Is there a terminal command I could use to split it in two equal folders so it would be easier for Nautilus to open one of them? Or maybe 4 folders?

share|improve this question
    
please define equal. Equal in size or equal in number of files? –  hakermania Sep 18 '12 at 8:51
    
In number of files, I suppose... ;) –  Frantique Sep 18 '12 at 8:54
2  
To open 80.000 files, split in 4 folders would still crash nautilus on a powerpc Imac G5!... you could try mkdir folder1 and then cp *.txt folder1 to copy every txt to folder1 and do so for extensions like cp *.jpg folder2 cp *.doc folder3 cp *.docx folder3. Nautilus should have a easier job to view them then. –  blade19899 Sep 18 '12 at 8:55
    
Forgot to mention all files are in .jpg format. –  user89004 Sep 18 '12 at 9:06
    
select folder with shotwell and let shotwell create folder dates and such –  blade19899 Sep 18 '12 at 9:09
add comment

2 Answers

ls -1 | sort -n | head -40000 | xargs -i mv "{}" /destination/folder/

Adjust head -40000 to fit your needs, also /destination/folder/

share|improve this answer
add comment

Try this script below i found it on Linuxquestions.org

PhotosPath="/media/4GBSD/DCIM/101CANON"
SortPath="/home/angus/.imagesort"
LibraryPath="/home/angus/Photos"
CameraPath="/media/4GBSD"
please rename these path to fit your needs

#!/bin/bash
#
#
PhotosPath="/media/4GBSD/DCIM/101CANON"
SortPath="/home/angus/.imagesort"
LibraryPath="/home/angus/Photos"
CameraPath="/media/4GBSD"
CharFromName=4
echo 
echo 
############
# Test to see if $PhotosPath exists, if not promp for new path / exit.
test -d $PhotosPath || read -p "$PhotosPath does not exist, close to exit or type new path:" PhotosPath
test -d $PhotosPath || "read -p '$PhotosPath is invalid. Press enter to close' && exit"

############
# move files from camera to $SortPath
mv $PhotosPath/* $SortPath/

############
# rename all image files in $SortPath
# FolderDateDD-HHMMSS.ext
jhead  -autorot -ft -nf%y%m%d-%H%M%S $SortPath/*

###########
# Sort files into folders using $CharFromName letters of the file name
#
ls $SortPath | while read file; do
 # extract first $CharFromName characters from filename
 FolderDate=${file:0:$CharFromName}
 # create directory if it does not exist
 test -d $LibraryPath/$FolderDate || mkdir $LibraryPath/$FolderDate
 # move the current file to the destination dir
 mv -v $SortPath/$file $LibraryPath/$FolderDate/$file
done

##########
# move sorted files into photo library
#mv -v $SortPath/* $LibraryPath/ 

##########
# Umount the card
umount $CameraPath

##########
# End notification
echo 
echo "Photos  from: $PhotosPath"
echo "End location: $LibraryPath"
echo 
echo "The card has been ejected."
echo 
read -p "Press enter to close this window…"
share|improve this answer
1  
Way too complicated but thanks for the hassle. The other guys solution is much easier. People need to get on with their lives you know, and not waste it in front of a Terminal. Technology is supposed to help you, not eat up all your time... –  user89004 Sep 18 '12 at 9:41
    
@Sergiu neither to destroy your pc either! The other solution is far too simple and I would not hesitate to characterize it dangerous. A for or while loop would do perfectly here. –  hakermania Sep 18 '12 at 10:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.