Convert A4 Size PostScript to PDF using GhostScript
psFile=<PostScript-File>; \ cat $psFile | \ gs -q -dNOPAUSE -sDEVICE=pdfwrite -sPAPERSIZE=a4 \ -sOutputFile=$(dirname $psFile)/$(basename $psFile .ps).pdf -
Merge Multiple pnm Files to one pdf File
gm convert *.pnm output.pdf
Rotate a Page from a pdf File
pageNum=5 # For example, Page 5 anticlockwise pdftk <Source-File> cat ${pageNum}west output out${pageNum}.pdf pageNum=3 # For example, Page 3 clockwise pdftk <Source-File> cat ${pageNum}east output out${pageNum}.pdf
Password Protect a pdf File
pdftk <Source-File> output <Protected-File> \ owner_pw <password-A> \ user_pw <password-B> <password-A> and <password-B> must be different, or simply omit owner_pw.
YouTube Download
youtube-dl "URL-of-Video-to-Download" e.g. youtube-dl "http://www.youtube.com/watch?v=Zcxh_XpuNS0" Requirements: 1) Use synoptic package manager to install "youtube-dl" 2) Update the installed version of youtube-dl: sudo youtube-dl -U 3) Update the installed version of youtube-dl a second time: sudo youtube-dl -U
Convert YouTube Downloaded .flv File to mp3
ffmpeg -i xxxx.flv -acodec libmp3lame xxxx.mp3 Requirements: 1) Use synoptic package manager to install "ffmpeg" 2) Use synoptic package manager to install "libavutil-extra-50"
Convert Apple QuickTime .mov File to mp4
ffmpeg -i xxxx.mov -vcodec h264 -acodec mp2 xxxx.mp4 Note: With ubuntu 22.04.1: vlc can be used to view the mov file. mpv can be used to view the mp4 file.
Convert ogg file to mp3
for i in *.ogg; do soundconverter -b -m audio/mpeg -s .mp3 $i done
Displaying and Modifying Tags in flac Files
flac Tags can be displayed via the command:
metaflac --list <flac-file> | grep comment
Tags can be replaced thus:
tag=<tag-name>
metaflac --remove-tag=$tag "--set-tag=$tag=<new-tag-value>" <flac-file>
where
<tag-name> is one of ALBUM
ARTIST
TITLE
TRACKNUMBER
DATE
GENRE
COMMENTS
To make cutting and pasting the examples easier:
tag=ALBUM; metaflac --remove-tag=$tag "--set-tag=$tag=XXX" <flac-file>
tag=ARTIST; metaflac --remove-tag=$tag "--set-tag=$tag=XXX" <flac-file>
tag=TITLE; metaflac --remove-tag=$tag "--set-tag=$tag=XXX" <flac-file>
tag=TRACKNUMBER; metaflac --remove-tag=$tag "--set-tag=$tag=XXX" <flac-file>
tag=DATE; metaflac --remove-tag=$tag "--set-tag=$tag=XXX" <flac-file>
tag=GENRE; metaflac --remove-tag=$tag "--set-tag=$tag=XXX" <flac-file>
tag=COMMENTS; metaflac --remove-tag=$tag "--set-tag=$tag=XXX" <flac-file>
For a GUI, one can use:
easytag &
Convert flac file to mp3 file
for i in *.flac; do title="$(metaflac --export-tags-to=- $i | grep TITLE | cut -d= -f2)" artist="$(metaflac --export-tags-to=- $i | grep ARTIST | cut -d= -f2)" album="$(metaflac --export-tags-to=- $i | grep ALBUM | cut -d= -f2)" year="$(metaflac --export-tags-to=- $i | grep DATE | cut -d= -f2)" track="$(metaflac --export-tags-to=- $i | grep TRACKNUMBER | cut -d= -f2)" comment="$(metaflac --export-tags-to=- $i | grep COMMENTS | cut -d= -f2)" flac -dc $i | \ lame -b 128 -m s \ --tt "$title" \ --ta "$artist" \ --tl "$album" \ --ty "$year" \ --tn "$track" \ --tc "$comment" \ - $(basename $i .flac).mp3 done
Convert mp3 file to flac file
for i in *.mp3; do ffmpeg -i $i $(basename $i .mp3).flac done
Make an Extract from a Movie
For example, make a 33 second extract starting after 10 seconds: ffmpeg -i input.mov \ -vcodec copy \ -acodec copy \ -ss 00:00:10 \ -t 00:00:33 \ output.mov Another version that might be better: ffmpeg -i input.mkv \ -c copy \ -avoid_negative_ts make_zero \ -ss 00:00:10 \ -t 00:00:33 \ output.mkv
Extract a Frame from a Movie
For example, extract the frame 20 seconds into the movie: ffmpeg -i input.mov \ -ss 00:00:20 \ -frames 1 \ output.jpg
Reduce File Size of a Photo
mogrify -scale 50% -quality 85% input.jpg Note: the original file will be overwritten!
Reduce Resolution of a Movie
For example, suppose the movie has a frame rate of 30 fps and pixel size 1920x1080. The following will reduce its size to 480x270: ffmpeg -i input.mov \ -framerate 30 \ -vf scale=480:270 \ output.jpg The -framerate option helps to suppress warning messages should the frame rate be anything other than 25 fps. The frame rate can be found with: ffmpeg -i input.mov after sorting through the copious output and ignoring any error messages.
Concatenate flac files
shntool join -o flac <flac-file> <flac-file> ... The output file is called joined.flac. Afterwards, remember to set tags in the output file.
Displaying and Modifying Tags in mp3 Files
mp3 Tags can be displayed via the command:
mp3info <mp3-file>
They can be modified thus:
mp3info -t "new-title" <mp3-file>
mp3info -a "new-artist" <mp3-file>
mp3info -l "new-album" <mp3-file>
mp3info -y "new-year" <mp3-file>
mp3info -g "new-genre" <mp3-file>
mp3info -c "comment" <mp3-file>
mp3info -n "new-track-number" <mp3-file>
For a GUI, one can use:
easytag &
Creating an m3u Playlist
Assume that <m3path> is set to the name of a directory containing several mp3 files. The following bash commands will create an m3u playlist of the files. The rather tedious use or quotation marks is intended to cope with spaces in file and direcory names: if [ -d "$m3path" ]; then m3uName="$(basename "$m3path").m3u8" echo "#EXTM3U" >| "/tmp/$m3uName" for f in "$m3path"/*.mp3; do echo ========================= "$f" info="$(mp3info -p "#EXTINF: %S,%a - %t" "$f")" echo "$info" >> "/tmp/$m3uName" echo $(basename "$f") >> "/tmp/$m3uName" done mv "/tmp/$m3uName" "$m3path" else echo -e \"$m3path\" is not a directory! fi
Optical Character Recognition, OCR
To perform Spanish and German OCR on a jpg file: jpgFile="P1000038.JPG" # for example baseName=$(echo $jpgFile | cut -d. -f1) # Handle both ".jpg" and ".JPG" names jpegtopnm $jpgFile > $baseName.pnm tesseract -l spa+deu $baseName.pnm $baseName The result will be in $baseName.txt.
Turn Off the ubuntu Logout Prompt
To turn Off the ubuntu Logout Prompt: gsettings set com.canonical.indicator.session \ suppress-logout-restart-shutdown true
The Panasonic Digital Camera Model DMC-FS35 is rather weak in its built-in folder manipulation capabilities. In particular, there is no way to get it to reset its photo number counter. The following link describes a way that one can do this:
lumixNotes.php
Giving an Image a Transparent Background with gimp
a) Open the image in gimp. b) Add an alpha-channel via Layer > Transparency > Add Alpha channel. c) Use a select tool, e.g. Fuzzy Select, to select the background area to be made transparent. d) Hit the Del key. e) Export the image as type png or gif.
Rotating a Movie by 90 degrees on Playback
90 degrees clockwise: mplayer -vf rotate=1 <video-file> 90 degrees counter-clockwise: mplayer -vf rotate=2 <video-file>
Rotating a Movie File by 90 degrees
90 degrees clockwise: mencoder <input-movie> -o <output-movie> -vf rotate=1 \ -oac pcm -ovc lavc 90 degrees counter-clockwise: mencoder <input-movie> -o <output-movie> -vf rotate=2 \ -oac pcm -ovc lavc
Rotating a Movie by 90 degrees
Note: the following does not handle the sound track of the movie. Doing that is a future project!
1) Extract all the frames of the movie into png files: mplayer <inputfile> -vo png:z=8 -ao null 2) Convert the png files to jpg files: for i in *.png; do pngtopnm $i | \ pnmtojpeg --quality=90 >| $(basename $i .png).jpg echo $i done 3) Rotate all the jpg files: for i in *jpg; do jpegtran -rotate 90 $i > /tmp/$i mv /tmp/$i . echo $i done 4) Merge the jpg files back into a movie: mencoder "mf://*.jpg" -mf fps=30 -o <outfile>.avi \ -ovc lavc -lavcopts vcodec=mpeg4 or avconv -f image2 -i %08d.jpg -r 30 <outfile>.avi
Scan MultiPages using Document Feeder
Load the pages to copy into the feeder. To scan in 15 pages, execute, for example: nPages=15 x=1; while [ $x -le $nPages ]; do echo $x scanimage -x 200 -y 290 \ --mode=Gray \ --resolution=300 >| img-$(printf %02d $x).pnm ((x++)) done To rotate the scanned files: nPages=15 x=1; while [ $x -le $nPages ]; do echo $x pnmrotate 90 \ img-$(printf %02d $x).pnm >| rimg-$(printf %02d $x).pnm ((x++)) done To convert the rotated files to PDF: for i in *; do echo $i convert $i $(basename $i .pnm).pdf done
Setting up a WAP-4033 Wireless Access Point from Planet
Follow this link.
Connecting an Android Device via its USB Cable
An Android USB device needs to be recognised by a ubuntu system when it is plugged in. It needs a configuration file in:
/etc/udev/rules.d/
For example, an ARCHOS tablet requires a file such as /etc/udev/rules.d/51-archos.rules:
> sudo cat /etc/udev/rules.d/51-archos.rules SUBSYSTEM=="usb", ATTR{idVendor}=="0e79", MODE="0666", GROUP="plugdev" >
And a Nokia 2.4 Smartphone requires a file such as /etc/udev/rules.d/52-nokia.rules:
> sudo cat /etc/udev/rules.d/52-nokia.rules SUBSYSTEM=="usb", ATTR{idVendor}=="0421", MODE="0666", GROUP="plugdev" >
It is necessary to find the Vendor-ID of the device being connected. This link contains a list of more Vendor-IDs.
Nokia Note: In order for Android Studio to be able to connect to a Nokia 2.4 Smartphone, the phone must:
Enabling USB Debugging Mode on a Nokia 2.4 Handy
The procedure described here works for Nokia 2.4 smartphones. It may also work for other android devices.
1) Select Settings → About phone. 2) Scrolldown to find Build Number. 3) Enable Developer Options by tapping Build Number about 7 times. 4) Now go to Settings → System. The menu item Developer Options should now be visible. 5) Select this menu item and find the item USB Debugging. Click on it to enable USB Debugging.
How to Install and Set Up dbWeave
1) Use synaptic to install wine. 2) Download the dbweave_setup.exe file from: https://www.brunoldsoftware.ch/dbw.html 3) Install dbWeave as root: sudo mkdir /opt/dbWeave sudo cp .../Downloads/dbweave_setup.exe /opt/dbWeave/ su - # wine /opt/dbWeave/dbweave_setup.exe and specify: Z:\opt\dbWeave\ as the installation directory. 4) dbWeave can then be started via: wine /opt/dbWeave/dbw.exe 5) Set up a ubuntu desktop file, maybe so: > cat /usr/share/applications/xfig.desktop [Desktop Entry] Exec=/opt/dbWeave/dbw.exe %f Name=db-Weave Comment=Weaving Setup Application Icon=/opt/dbWeave/DBW.png Terminal=false Type=Application Categories=Weaving; >
How to Clone an Android Project under eclipse
Using eclipse to develop apps for android, I have not found any simple way of duplicating a project to my satisfaction. The following seems to work. I'd appreciate suggestions on how to simplify it.
Suppose that one has an eclipse project called old_proj, and one wants to duplicate it, calling the new project new_proj:
a) Ensure that all packages/projects in the Package Explorer view of eclipse are collapsed. My version of eclipse has a button that does that in a single click. b) Select project old_proj in the Package Explorer view, and copy it via Edit --> Copy. c) Paste the copied project via Edit --> Paste. When prompted for a new name, specify a provisianal name, e.g. xxxx. d) Click on the new project, xxxx, in the Package Explorer view, and select Refractor --> Rename... Specify the desired new name, e.g. new_proj, ensure that Update references is checked, and click OK. e) Continue in a terminal window: i) > op=old_proj > np=new_proj ii) Set the current working directory to the base of the new project, e.g.: > cd ~/android/workspace/$np/ iii) Delete the bin and gen directory trees: > rm -Rf bin gen and, if the old project was checked into CVS, remove all CVS directories: > for i in $(find . -name CVS); do rm -Rf $i; done iv) Find all directories having the old project name, and rename them to the new project name, e.g.: > for i in $(find . -type d -name $op); do mv $i $(dirname $i)/$np; done v) Find all files containing references to the old project name, e.g.: > find . -type f -exec grep -l $op {} \; These should all be ASCII files, which can be edited using sed. Check that this is the case before continuing to Step v). vi) Replace all references to the old project name with references to the new project name, thus: > for i in $(find . -type f -exec grep -l $op {} \;); do sed -e s/$op/$np/g $i >| /tmp/xxxx; mv /tmp/xxxx $i; done f) Return to eclipse, select the new project in the Package Explorer window and then File --> Refresh. There will probably be a message about the package definition having changed in the Manifest, with a question about updating the Launch Configuration. This can be answered with Yes. g) Finally select Project --> Clean.... Ensure that the new project is checked, and click OK
Assuming that the old project was OK, the new one should now also be OK and have no references to the old project.
How to Encrypt a File
Execute the following program on the Wolfligstrasse <pc>. java -jar "/home/david/netBeansProjects/EncryptFile/dist/EncryptFile.jar" <startPath> where <startPath> is the default starting directory. Default is one's home directory. The program lets one browse to pick the file to encode and then prompts for an encryption key. The encrypted file will be written to the directory holding the file to be encrypted, and its file name will have ".enc" appended.
How to Capture Screen Video
Use kazam or simplescreenrecorder
How to pair Logitech Unifying Devices on Linux
Use solaar