I have a directory with thousands of video file. How can I move 15 of the files (video.mp4) to another location.
Asked
Active
Viewed 80 times
-1
-
1Do you know their names? – Andy Dalton Aug 29 '20 at 22:42
-
Or, if it is just 15, try `ls | head -15` and `mv` those files to the other location. – Ljm Dullaart Aug 29 '20 at 22:55
-
no just move name It does not matter to me – user430552 Aug 30 '20 at 03:43
-
With zsh, this may help: https://unix.stackexchange.com/a/48486/117549 – Jeff Schaller Aug 30 '20 at 12:40
2 Answers
1
Your mv tag already gives the solution. man mv states:
Name: mv - move (rename) files
Synopsis:
mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE...
Description:
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
<...>
If you use ls to find 15 file names, you can move them with mv.
Ljm Dullaart
- 4,142
- 11
- 26
0
i find a script and mod it for this work
#!/bin/bash
c=1; d=1; mkdir -p NEWDIR_${d}
for mpeg_file in *.mp4
do
if [ $c -eq 15 ]
then
d=$(( d + 1 )); c=0; mkdir -p NEWDIR_${d}
fi
mv "$mpeg_file" NEWDIR_${d}/
c=$(( c + 1 ))
done
user430552
- 1
- 1