ls -1 | sort -n | head -40000 | xargs -i mv "{}" /destination/folder/
Ajuste head -40000
para atender às suas necessidades, também /destination/folder/
Eu tenho uma pasta com 80.000 arquivos no meu iMac G5 rodando o Ubuntu 12.04.1 e nem consigo abri-lo com o Nautilus porque ele congela.
Eu posso fazer ls -a
no Terminal e isso me mostra tudo.
Existe um comando de terminal que eu poderia usar para dividi-lo em dois diretórios igualmente dimensionados (em termos de número de arquivos), de modo que seria mais fácil para o Nautilus abrir um deles? Ou talvez 4 pastas?
ls -1 | sort -n | head -40000 | xargs -i mv "{}" /destination/folder/
Ajuste head -40000
para atender às suas necessidades, também /destination/folder/
Experimente este script abaixo que eu encontrei em Linuxquestions.org
PhotosPath="/media/4GBSD/DCIM/101CANON"
SortPath="/home/angus/.imagesort"
LibraryPath="/home/angus/Photos"
CameraPath="/media/4GBSD"
por favor, renomeie este caminho para atender às suas necessidades
#!/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…"
Tags command-line