フォルダーを2つに分割するターミナルコマンドはありますか?


8

Ubuntu 12.04.1を実行しているiMac G5に80.000ファイルのフォルダーがあり、フリーズしているためNautilusでそれを開くこともできません。

ls -aターミナルで実行でき、すべてが表示されます。

Nautilusがそのうちの1つを開くのが簡単になるように、(ファイル数に関して)2つの同じサイズのディレクトリに分割するために使用できる端末コマンドはありますか?それとも4つのフォルダ?


2
まだPowerPCの量Imac G5のクラッシュオウムガイは!...あなたは試みることができるでしょう80.000ファイル、4つのフォルダ内の分割を開くにはmkdir folder1、その後cp *.txt folder1のすべてをコピーするtxtfolder1などの拡張のためにそうしますcp *.jpg folder2 cp *.doc folder3 cp *.docx folder3。ノーチラスは、それらを表示するより簡単な仕事をする必要があります。
blade19899 2012

すべてのファイルが.jpg形式であることを言及するのを忘れました。

ショットウェルのあるフォルダーを選択し、ショットウェルにフォルダーの日付などを作成させます
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もあなたのPCを破壊しないでください!他の解決策は非常に単純すぎるため、私はそれを危険であると特徴づけることを躊躇しません。forまたはwhileループは、ここでは完全に機能します。
hytromo 2012
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.