Ubuntu – How to batch copy files sequentially from one folder to another

bashcommand line

I have a music player that ridiculously enough, refuses to play files according to the alphabetical and numerical order, but based upon the order in which they are copied to the audio player.

As such, I have for years copied files one at a time from my music folder to the folder in the music player to ensure they keep to their playlist order. Now that I have a few audio books, it would be a lot easier to automate the process explicitly with a bash script or any other solution.

Simply doing a Ctrl-A and Ctrl-V results in different files being copied and pasted at different times to the music folder. It's a problem if this results in the last chapter of an audio book being played before it should.

For example: c01.mp3, c02.mp3, c03.mp3 when copied to the audio player may be played in the order c03.mp3, c01.mp3, c02.mp3 instead of the correct numerical order.

My question is, what would be the best way to simplify the process?

Best Answer

If the files are in lexicographic order, the simplest way is:

cp * /path/to/player

If you use a loop-based approach, be sure to quote the variables ("$i") to handle filenames with spaces.