cp modification

I'm usia Raspbian, a Debian subset, and wondering what work would be involved in altering the cp command.

cp at present needs a full path and file name for source and at least full filename for destination. How can I change this so the second parameter isn't needed? So if the destination filename isn't given the source filename is assumed?

Many thanks.

*nix isnt windows... windows creates a "copy" file only macosX offers something similar since it downloads you dont know why sometimes files you only downloaded but just wanted to look at ( often PDF files...) adding (X) to the file name and incrementing X.

To my knowledge no modern unix would accept that you cp a file on itself, allowing it would end with a file size 0, so you must give second parameter and it should be at least an existing directory ( file is optional if keeping the same name )

Your only choice if you dont want to give a second parameter because the file will be in the same directory is to write a script where you use the the first param for the second adding an extension to the original file name

The file would never be in the same directory, that wouldn't make any sense.

Example:

I want to copy the file / mnt/g/blender/projects/raider_ship_3000_frame_test_run.blend

And I want to copy the file to my current directory /mnt/backup

I just don't want type the file file name.

1) it's boring.
2) Introducing typos is easy.

And I'm working with a lot of files.
the cp command 'assumes' the current directory to be the destination directory if not specified, I'm just asking if the file name can be assumed to be the same if not specified.

Maybe you can consider cp -t ?

       -t, --target-directory=DIRECTORY
	      copy all SOURCE arguments into DIRECTORY

See also rsync, which is intended for synchronizing directories and available most anywhere.

Do not give in to the mental block of it "not being cp". You are allowed to use a tool that was actually designed to do the job you had in mind.

With any standard version of the cp utility, the command:

cp file1 file2 file3 /destination/directory

will copy files file1 , file2 , and file3 from your current working directory into files named /destination/directory/file1 , /destination/directory/file2 , and /destination/directory/file3 .

What makes you think you need to modify the cp utility to get this standard behavior?

If all your files are in /mnt/g/blender/projects you could try one of

$ cp /mnt/g/blender/projects/* .
$ cp /mnt/g/blender/projects/{file1,file2,file3} .
$ cd /mnt/g/blender/projects; cp file1 .... filen /mnt/backup

If they are in multiple different directories it's a little more difficult.

If all your files are in different directories, all under, say /mnt/g/blender , and I assume you are using bash as your shell, you could try this:

$ cd /mnt/g/blender
$ shopt -s globstar
$ cp **/file1 **/file2 .... **/filen /mnt/backup

globstar is a bash shell option that expands **/ into all subdirectories.

Otherwise I don't think you can do what you want.

Andrew