Esiste un comando terminale per dividere una cartella in due?


8

Ho una cartella con 80.000 file sul mio iMac G5 con Ubuntu 12.04.1 e non riesco nemmeno ad aprirlo con Nautilus perché si blocca.

Posso fare ls -ain Terminal e mi mostra tutto.

Esiste un comando terminale che potrei usare per dividerlo in due directory di dimensioni uguali (in termini di numero di file) in modo che Nautilus possa aprirne una più facile? O forse 4 cartelle?


2
Per aprire i file di 80.000, suddivisa in 4 cartelle sarebbe ancora nautilus incidente su un PowerPC Imac G5! ... si potrebbe provare mkdir folder1e quindi cp *.txt folder1di copiare ogni txta folder1e farlo per estensioni come cp *.jpg folder2 cp *.doc folder3 cp *.docx folder3. Nautilus dovrebbe quindi avere un lavoro più semplice per visualizzarli.
blade19899,

Hai dimenticato di menzionare che tutti i file sono in formato .jpg.

seleziona la cartella con shotwell e lascia che shotwell crei le date delle cartelle e così via
blade19899

Risposte:


10

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

Adatta anche head -40000alle tue esigenze/destination/folder/


1

Prova questo script qui sotto l'ho trovato su Linuxquestions.org

PhotosPath="/media/4GBSD/DCIM/101CANON"
SortPath="/home/angus/.imagesort"
LibraryPath="/home/angus/Photos"
CameraPath="/media/4GBSD"

rinominare questo percorso in base alle proprie esigenze

#!/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…"

1
Troppo complicato ma grazie per la seccatura. La soluzione degli altri ragazzi è molto più semplice. Le persone hanno bisogno di andare avanti con le loro vite che conosci e non sprecarle davanti a un Terminale. La tecnologia dovrebbe aiutarti, non mangiare tutto il tuo tempo ...

@Sergiu nemmeno per distruggere il tuo pc! L'altra soluzione è fin troppo semplice e non esiterei a definirla pericolosa. Un ciclo for o while farebbe perfettamente qui.
hytromo,
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.