It sounds like you're trying to make a video. If that's the case, then I'd use a proper video format.
In this case, I'd use ffmpeg to convert the individual PNG files to a H.264 video. Since ffmpeg is made to work with videos that can be hours long, it should have no problem with your thousands of images. Using H.264 instead of animated gif will result in a vast improvement in image quality.
Something like this should work for you:
ffmpeg -framerate 1/2 -i img%04d.png -c:v libx264 -r 30 out.mp4
-framerate 1/2
: This sets the framerate to one-half FPS, or 2 seconds per frame.
-i img%04d.png
: This tells ffmpeg to read the files img0000.png
though img9999.png
.
-c:v libx264
: Use video codec libx264.
- You can specify video compression parameters here, if you like:
-crf <number>
: Quality setting. 0 to 51. 23 is the default. 0 is true lossless encoding, which will be quite high bandwidth. 18 is nearly visually lossless.
-r 30
: Set the output framerate to 30 FPS. Each of the input images will be duplicated to make the output what you specify here. You can leave this parameter off, and the output file will be at the input framerate, but the resulting movie didn't display properly when I tried it just now.
out.mp4
: Output filename.
References:
Ok, so you need to replace the first two and the last space in every line with a comma. You can't just replace every space, because the 3rd field may contain spaces itself. You can do this with regular expression replacement. Here's a sed script/command, that works:
sed -re 's/^(\S*) (\S*) (.*) (\S+)\s*$/\1,\2,\3,\4/' in.txt > out.csv
With the above example this returns:
Account,Units,Description,Delta
2281,19,Toshiba PX-1982GRSUB,0
9618,200,HP MX19942-228b,-25
19246,4,CompuCom HD300g Hard Drive,4
This is still quite fragile with handling empty fields and breaks entirely, if columns other than the 3rd contain spaces. It's very easy to introduce such malformed data if it is formatted manually as done by your boss. You should suggest to him to switch to a more robust table format (e. g. proper CSV & Co.) and editor (common spread sheet tools can manipulate CSV quite well and flexibly, e. g. LibreOffice/OpenOffice Calc, Microsoft Excel and Google Docs).
Best Answer
Find can be used for this, but I find it easier to use the shell instead. If your files are all in the same directory (no subdirectories) you can just do:
The
${var%something}
syntax will remove the shortest match for the globsomething
from the end of the variable$var
. For example:So here, it is removing the final extension from the filename. Therefore,
"${f%.*}.gif"
is the original file name but with.gif
instead of.jpg
or.JPG
.If you do need to recurse into subdirectories, you can use bash's
globstar
option (fromman bash
):You can enable it with
shopt -s globstar
: