+5 votes
in Operating Systems by (54.2k points)
I am using the "mv" command to move about 150k ".jpg" files from one folder to another, but it returns an error - "Argument list too long". It seems that I cannot use the "mv" command to move such a large number of files. Is there any other way to do this job?

1 Answer

+2 votes
by (346k points)
selected by
 
Best answer

It's true that the "mv" command cannot be used to move a large number of files from one folder to another.

You can use the "find" command with its "exec" parameter to run the "mv" command. To move only ".jpg" files, you can use the parameter "name" to specify it.

The syntax of the command should be as below:

find source_folder -name "*.jpg" -exec mv {} destination_folder/ \;


...