I have more .mp3 files such as :
t001.mp3 t002.mp3 t003.mp3 .....
e001.mp3 e002.mp3 e003.mp3 .....
I would like to merge :
t001.mp3 and e001.mp3 ->>>> r001.mp3
t002.mp3 and e002.mp3 ->>>> r002.mp3
t003.mp3 and e003.mp3 ->>>> r003.mp3
something like this.
What is the best way to do this command? have an application or batch command?
If you are on Linux you can simply use cat file1 file2 > file3 command to concatenate the files and get merged mp3 file which would play the above in sequence.
Similar functionality is available in other Operating Systems including Windows eg: (type file1 file2 > file3) as well.
More info is available in the following related question.
Using cat to join mp3 files. What is this black sorcery?
Cheers!!!
I've use MP3Wrap, a command-line tool, successfully. It can be used at the comand prompt or in batch files. Some commands for its use:
mp3wrap combinedfiles.mp3 file*
To wrap all the files in a directory:
mp3wrap combinedfiles.mp3 *
or
mp3wrap combinedfiles.mp3 *.*
Two or more files:
mp3wrap combinedfiles.mp3 file1.mp3 file2.mp3 etc.
Related
I am working with a bunch of txt files(thousands) on my project. Each txt file has 'csv' information on it. The problem is that each txt file has a random name and I cannot create a code for loading them in my project due to it. So, I want to rename them in a particular pattern to make easier the loading of the files in my work. I will use C++ for accomplish this task.
I put all the txt files in a folder but I cannot see a way of renaming them using C++. How can I do this? is there a way to do it? Can someone help me?
You can use std::filesystem::directory_iterator and std::filesystem::rename (c++17), as documented here.
Disclaimer
This answer validity is based on a comment where the author precised they were not bound to the C++ language (it may be worth editing the question, the C++ tag, and the OS). This solution may work for UNIX systems supporting bash, that is most Linux distributions and all releases of Apple's macOS prior to macOS Catalina (correct me if I'm wrong).
Bash command line
Using the following bash command should rename all the files in a folder with increasing numbers, that is:
toto.csv -> 1.csv
titi.csv -> 2.csv etc
It assumes the ordering is not important.
a=1; for i in *; do mv -n "$i" "$a.csv" ; let "a +=1"; done
To test it, you can prepare a test folder by opening a terminal and typing:
mkdir test
cd test
touch toto.csv titi.csv tata.csv
ls
Output:
tata.csv titi.csv toto.csv
Then you can run the following command:
a=1; for i in *; do mv -n "$i" "$a.csv" ; let "a +=1"; done
ls
Output:
1.csv 2.csv 3.csv
Explication:
a=1 declare a variable
for i in *; begin to iterate over all files in the folder
do mv will move (rename) a file of the list (that is, the variable $i) to a new name called a.csv
and we increment the counter a, and close the loop.
the option -n will make sure no file gets overwritten by the command mv
I assumed there was no specific criterion to rename the files. If there is a specific structure (pattern) in the renaming, the bash command can probably accommodate it, but the question should then give more details about these requirements :)
I have a folder and subfolder which contain many HTML files. I want to store all the html file paths to an array. I am using C++ and ubuntu.
I know a terminal command - find . -name *.html which gives me all the html file paths.
I want to use these paths to create PDF of these HTML files using WKHTMLTOPDF and threading. How to store these paths and use it?
You could brute-force it by using std::system
http://en.cppreference.com/w/cpp/utility/program/system
to execute your find command and use the output in a C++ program. Or read up on file system traversal in Steven's APUE ('Advanced Programming in the Unix Environment) and do it yourself. Begin with man 3 stat.
I would like to attach all .csv files from /home/john recursively, something like the following would be fine but only attaches all .csv files from /home/john/ it doesnt include all the sub folders of /home/john/
mutt -s "all csv files" me#mail.com -a /home/john/*.csv < /home/john/message.txt
but what if I can do this and if there happens to be a .csv file in one of the sub folders with the same name? eg /home/john/1.csv and /home/john/tom/1.csv what will happen? will it still be attached?
thanks
No that command wont't find *.csv in subdirectories. You may want to use find and xargs, something like this:
find /home/john -name \*.csv | xargs mutt -s "all csv files" me#mail.com -i /home/john/message.txt -a
I think -i would have the same effect as < from the file.
I am new to regular expressions.
I have many irregularly numbered ascii files with no extension: g000554, g000556, g000558, g000561, g000563 ... g001979 etc
I would like to type a regex at the terminal (or in a short script) to add a .dat to all of these files.
So I would like to change them to become: g000554.dat, g000556.dat, g000558.dat, g000561.dat, g000563.dat ... g001979.dat etc
p.s. Sorry I should have provided more info: by terminal I meant a mac terminal and I cannot use the 'rename' command.
I think you're using a linux system. So i provide a bash solution. It works only if your files starts with g and there is no other files in that directory except the files you want to rename.
for i in g*; do mv "$i" "$i.dat"; done
The below would add .dat extension to all the files present in the current directory,
for i in *; do mv "$i" "$i.dat"; done
I have many 1GB csv files. What is the easiest way to merge them. Can this be done using shell commands or do I have to write a C++ program for it.
cat *.csv > mega-merged.csv2
mv mega-merged.csv2 mega-merged.csv
(The use of the .csv2 is so that the *.csv doesn't catch it.)
Re Joce's comment, if you have headers, you can trim off all the headers (on GNU/Linux or any other platform with GNU tools) using something like:
tail -qn +2 *.csv > mega-merged.csv2