1

対応する数のフォルダにまたがる約1,000個のファイル(拡張子なし、つまり、、など)の大規模なコレクションがあり1105ます。つまり、次のような1000個のファイルです。11065231

/users/me/collection/1105/1455、、、/users/me/collection/1106/1466など/users/me/collection/1110/1470など。

私がやりたいのは、サブディレクトリ(つまり、、、など)内のこれらすべてのファイルを1つのディレクトリ(つまり)に移動する簡単な方法を1455見つける1466こと1470です/users/me/collection-all/

正直なところ、拡張子がないので気が遠くfindなり、ファイルと一緒にディレクトリを保持しているようです...実際にはすべてPDFですが、拡張子はありません。

4

4 に答える 4

4

実際、答えは非常に簡単です。

それらを見つけてディレクトリを除外できます:

cp ` find <your directory tree base> ! -type d` <your destination directory>

「! -type d」は、タイプ「ディレクトリ」の結果を当然除外します。

HTH

于 2012-04-23T13:12:42.880 に答える
1

これはどう?

mv /users/me/collection/*/* /users/me/collection-all/
于 2012-04-23T13:19:56.127 に答える
1

私の2セント

cd /users/collections/me
find . -type f -exec mv {} /users/me/collection-all/ \;
于 2012-04-23T13:21:32.990 に答える
1

これを試すことができます:

#!/bin/bash

IFS_BACKUP=$IFS
IFS=$'\n\t'

for i in $(find $source_directory -type f -iname "*" -print)
do
  mv -nv "$i" "$target_directory"
done

IFS=$IFS_BACKUP

exit

変数$source_directory$target_directory適切なパスに置き換えてください。

于 2013-08-17T00:33:34.993 に答える