Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Copy a source file to multiple copies....
Author | Message | ||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9055 |
Hello all. Merry Christmas and all that.... I have a need to copy one file, to multiple files in the same directory/folder. The file is a 2-second blank WAV file. I need to copy this file up to a couple of hundred times, with the filename incremented in number for each copy. Does anyone know of anything that can do that? I could do it manually, but that is A-LOT of file-copy-and-rename processes. The files are only blank WAV files, so as to preserve the file-number reference when a project calls for a certain file NUMBER from the MP3 player module. I have about 50 separate WAV files, but the last one on the system is used as a global reset and it needs to be 255.WAV In order for that to work with the DFplayer module, I need a hundred or so 'Blank' WAV files in the directory, so that when I call file #255, it is actually #225 in the FAT. DRIVESORT will make sure all the files are in the correct order on the uSD card, so that everything works as expected, but I still need to duplicate one blank WAV file to many other filenames in the same directory, so that all the filenames are present - even though I may never want file #192 for example, but it has to exist in the FAT for the player to work correctly. Clear as mud? Smoke makes things work. When the smoke gets out, it stops! |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5886 |
That looks like a job for MMBasic- DOS version VK7JH MMedit  MMBasic Help |
||||
Quazee137 Guru Joined: 07/08/2016 Location: United StatesPosts: 522 |
try this if you on linux for i in {1..200}; do cp blank.wav "blank$i.wav"; done Edited 2019-12-25 19:51 by Quazee137 |
||||
SimpleSafeName Senior Member Joined: 28/07/2019 Location: United StatesPosts: 286 |
You'll need a file called "0.wav" to run this. Copy the method that you prefer into "MultiCopy.bat" and run it. Enjoy! Run this if you want leading pad zeros (i.e. "001.wav"): @echo off for /L %%i IN (1,1,255) do call :docopy %%i goto :EOF :docopy set FN=00%1 set FN=%FN:~-3% copy 0.wav %FN%.wav :EOF Run this if you don't: @echo off for /L %%i IN (1,1,255) do call :docopy %%i goto :EOF :docopy copy 0.wav %1.wav :EOF |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5886 |
Adjust the formatting to suit your requirements. Jim VK7JH MMedit  MMBasic Help |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9055 |
Excellent suggestions - thanks chums! The thought of having to manually create and rename 200 or so files...... EDIT: Just for anyone else reading this who is not familiar with the cheap MP3/WAV music player modules such as the DFplayer, they play files from the root directory of the uSD card you have inserted, BUT they are 'Dumb' modules to some extent, and have very limited file handling abilities - understandable when you consider how cheap they are etc. Files on the uSD card MUST be saved in the FAT(file allocation table) in the correct order, or the wrong file will play. The file for 005.WAV for example, has to be the fifth entry in the FAT, or the wrong file will play. [:p] Also, copying files from Windoze etc complicates things even more, as if you take a batch of ten WAV files, and copy them in one go to the uSD card, WINDOZE or LINUX etc will play the correct one if you click on it, but the actual copy order could be something totally random like: 8,2,1,5,7,9,10,3,4,6. Then you ask the DFplayer to play song #3, and you will get song #1!!!! Ask it for song #10, and you will get song #6..... Confusing as hell for newcomers to those kind of player module! Easy-peasy to fix with additional files to pad-out the FAT to the correct number, and a utility such as DRIVESORT to sort the FAT into the correct ascending order - then everything works as expected, but all this is to say that it is a really good 'Gotcha!' if you are new to using these player modules, as they work specifically from the FAT entries, and don't really care about what the filename entry is itself per-se'. Good fun! Edited 2019-12-26 09:37 by Grogster Smoke makes things work. When the smoke gets out, it stops! |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9055 |
Jim was right - this was easy in MMBASIC for DOS: Took about 20 seconds to copy to 255 files. Edited 2019-12-26 17:17 by Grogster Smoke makes things work. When the smoke gets out, it stops! |
||||
Print this page |