Move all .txt files into one directory
5,978
find
solution:
find all -type f -name "*.txt" ! -path "all/txt/*" -exec echo mv -t all/txt '{}' \;
Related videos on Youtube
Author by
xRobot
Updated on September 18, 2022Comments
-
xRobot over 1 year
I have almost 6000 directories with thousands of files:
all/recup_dir.1/1.txt all/recup_dir.1/2.jpg ... all/recup_dir.5987/1.txt all/recup_dir.5987/2.txt ...
and I want to move all .txt files in the all/txt folder. I have used this command:
mv **/*.txt txt
but I get this error:
bash /bin/mv arg list too long
How can I do?
-
stefan about 6 yearsif you just move all .txt files from your example to a common folder, the ones with the same basenames (e.g.,
1.txt
) will overwrite each other. How do you want to resolve this conflict? -
xRobot about 6 years@stefan I could rename it with 1-1.txt, 1-2.txt, 1-3.txt, ecc
-