Wednesday 24 August 2011

To many arguments for mv / cp.

If you have to copy large number of files from one directory to another from console level (for example trough ssh) and you see message like "Too many arguments to proceed" there are few solutions. The best in my opinion is these using "find" command.

find . -iname "*.EXT" -exec cp {} -l /DST_PATH/ \;
Where EXT is extension of files you want to copy. If you want to copy all files set it to "*" . DST_PATH is destination path where you want to copy files.

You have to call this command from source path, so af first change your current directory to source by "cd" command.

If you want to copy all files from current directory but not from subdirectories here is solution with -maxdepth parameter.

find . -maxdepth 1 -iname "*.EXT" -exec cp {} -l /DST_PATH/ \;

 Good luck :)

No comments:

Post a Comment