Есть ли терминальная команда для разделения папки на две части?

У меня есть папка с 80 000 файлов на iMac G5 под управлением Ubuntu 12.04.1, и я даже не могу открыть ее с помощью Nautilus, потому что она зависает.

Я могу сделать ls -a в Терминале, и он показывает мне все.

Есть ли терминальная команда, которую я мог бы использовать, чтобы разделить ее на две одинаковые по размеру (по количеству файлов) директории, чтобы Наутилусу было легче открыть одну из них? Или, может быть, 4 папки?

8
задан 6 February 2017 в 16:02

2 ответа

Попробуйте этот скрипт ниже, я нашел его на Linuxquestions.org

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

, пожалуйста, переименуйте этот путь в соответствии с вашими потребностями

#!/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…"
0
ответ дан 6 February 2017 в 16:02

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

Настройте head -40000 в соответствии со своими потребностями, а также /destination/folder/

0
ответ дан 6 February 2017 в 16:02

Другие вопросы по тегам:

Похожие вопросы: