是否有终端命令将文件夹一分为二?


8

我在运行Ubuntu 12.04.1的iMac G5上有一个包含80.000个文件的文件夹,我什至无法用Nautilus打开它,因为它冻结了。

我可以ls -a在Terminal中进行操作,它向我展示了所有内容。

是否可以使用终端命令将其分成两个大小相等的目录(就文件数而言),这样Nautilus可以更轻松地打开其中一个目录?还是4个文件夹?


2
要打开的文件80.000,分割在4个文件夹仍然在一个PowerPC的iMac G5崩溃鹦鹉螺!...你可以尝试mkdir folder1,然后cp *.txt folder1以每复制txtfolder1和喜欢的扩展这样做cp *.jpg folder2 cp *.doc folder3 cp *.docx folder3。鹦鹉螺应该可以更轻松地进行查看。
blade19899 2012年

忘记提及所有文件均为.jpg格式。

选择文件夹肖特韦尔让肖特韦尔创建文件夹的日期,例如
blade19899

Answers:


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也不破坏您的电脑!另一个解决方案太简单了,我会毫不犹豫地将其描述为危险。for或while循环将在此处完美地完成。
hytromo's
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.