มีคำสั่งเทอร์มินัลเพื่อแบ่งโฟลเดอร์ออกเป็นสองโฟลเดอร์หรือไม่?


8

ฉันมีโฟลเดอร์ที่มีไฟล์ 80,000 ไฟล์บน iMac G5 ที่ใช้ Ubuntu 12.04.1 และฉันไม่สามารถเปิดด้วย Nautilus ได้เพราะมันค้าง

ฉันสามารถทำได้ls -aใน Terminal และมันแสดงให้ฉันเห็นทุกอย่าง

มีคำสั่งเทอร์มินัลที่ฉันสามารถใช้เพื่อแยกออกเป็นสองขนาดเท่า ๆ กัน (ในจำนวนไฟล์) ไดเร็กทอรีดังนั้นมันจะง่ายกว่าสำหรับ Nautilus ที่จะเปิดหนึ่งในนั้นหรือไม่? หรืออาจจะ 4 โฟลเดอร์


2
หากต้องการเปิดไฟล์ 80,000 ไฟล์การแยกเป็น 4 โฟลเดอร์จะยังคงมีข้อผิดพลาด nautilus บน powerpc Imac G5! ... คุณสามารถลองmkdir folder1แล้วcp *.txt folder1คัดลอกทุกไฟล์txtไปยังfolder1ส่วนขยายcp *.jpg folder2 cp *.doc folder3 cp *.docx folder3ได้ Nautilus ควรจะมีงานง่ายขึ้นในการดูพวกเขาแล้ว
blade19899

ลืมพูดถึงไฟล์ทั้งหมดที่อยู่ในรูปแบบ. jpg

เลือกโฟลเดอร์ที่มี shotwell และให้ shotwell สร้างวันที่ของโฟลเดอร์และเช่นนั้น
blade19899

คำตอบ:


10

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

ปรับhead -40000ให้เหมาะกับความต้องการของคุณด้วย/destination/folder/


1

ลองใช้สคริปต์ด้านล่างนี้ฉันพบมันใน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…"

1
มันซับซ้อนเกินไป แต่ขอบคุณสำหรับความยุ่งยาก วิธีแก้ปัญหาอื่น ๆ นั้นง่ายกว่ามาก ผู้คนจำเป็นต้องดำเนินชีวิตต่อไปด้วยชีวิตที่คุณรู้จักและไม่ทิ้งมันไว้หน้าอาคารผู้โดยสาร เทคโนโลยีควรจะช่วยคุณไม่ให้กินตลอดเวลา ...

@Sergiu ไม่ทำลายพีซีของคุณเช่นกัน! วิธีอื่นง่ายเกินไปและฉันจะไม่ลังเลที่จะอธิบายว่ามันอันตราย สำหรับหรือในขณะที่วงจะทำอย่างสมบูรณ์แบบที่นี่
hytromo
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.