Posts

Showing posts with the label Command Line

Bulk Crop Images From CMD/PowerShell

Answer : ImageMagick is a light-weight tool that can be used for this. Here is an example that croppes all jpg images in a directory and puts the results in a new folder: cd path/to/dir/ mogrify -crop +100+10 -quality 100 -path ../cropped *.jpg Here, 100 pixels from the left border and 10 pixels from the top are removed. See here for more information on how to use crop. Have you tried XnCovert? XnConvert is free cross-platform batch image processor, allowing you to combine over 80 actions. Compatible with 500 formats. It uses the batch processing module of XnViewMP and it is freeware and you can donate them if you find it useful. https://www.xnview.com/en/xnconvert/

Add Android-studio/bin/ To PATH Environmental Variable

Answer : It looks like you edited this code snippet: if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi which is included in ~/.profile by default. The answer which lead you to do so is confusing IMNSHO. I'd suggest that you change that code back to what it looked like before, and instead add a new line underneath it: if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi PATH="$PATH:/usr/local/Android/android-studio/bin" Then, next time you log in, PATH ought to be altered, whether $HOME/bin exists or not.

7-Zip Doesn't Ask Me For A Password For A ZIP File I Encrypted While Double-clicking It

Answer : The ZIP format doesn't allow for encrypting file lists. This means that file lists are viewable by anyone. Only the contents of the files is encrypted, which means that no one can read the file without your password. Due to this, 7-Zip only asks for your password before unzipping. If you need a format that encrypts the file list, use 7Z and make sure you check "Encrypt File Names". For the more technical minded, the ZIP specification doesn't allow for encryption of the Central Directory. You will be prompted for a password when you try to extract the files. To simply view the contents of the archive does not require a password. If you would like to obfuscate the contents of the archive, compress the directory into an archive, and then compress that archive with a password. Thus, you will have to extract the archive with a password, to pull out the archived (and obfuscated) contents. A generalized solution that works for all zip programs (WI...

Batch Convert H.265 Mkv To H.264 With Ffmpeg To Make Files Compatible For Re-encoding

Answer : Yes, using ffmpeg . Open a terminal and direct it to the directory containing the H.265 encoded files, assuming you have ffmpeg and the appropriate libraries installed and assuming they are in MKV format copy and paste the following into the terminal window. INPUT="$1" for i in *.mkv ; do ffmpeg -i "$i" -bsf:v h264_mp4toannexb -sn -map 0:0 -map 0:1 -vcodec libx264 "$i.ts" mv "$i.ts" "$i.mpg" sleep 3 done There you have it. This will convert to h.264 in an MPG container in the same directory. Explanation of the command switches: for i in *.mkv ; do ... done This sets up all .mkv files in a directory to be included in the batch process. This may be changed to accommodate the container extension of the files you wish to process. ffmpeg -i "$i" Executes the program ffmpeg and calls for files to be processed. -bsf:v activates the video bit stream filter to be used. h264_mp4toannexb - Is...

Bash CLI Remove Quotes From Output Of A Command

Answer : You can use the tr command to remove the quotes: my_json=$(cat ~/Downloads/json.txt | jq '.name' | tr -d \") In the particular case of jq , you can specify that the output should be in raw format: --raw-output / -r: With this option, if the filter´s result is a string then it will be written directly to standard output rather than being formatted as a JSON string with quotes. This can be useful for making jq fil‐ ters talk to non-JSON-based systems. To illustrate using the sample json.txt file from your link: $ jq '.name' json.txt "Google" whereas $ jq -r '.name' json.txt Google

7-Zip Command Line: Extract Silently/quietly

Answer : 7-Zip does not have an explicit "quiet" or "silent" mode for command line extraction. A similar question over at Stack Overflow, Extracting a 7-Zip file "silently" - command line option , gives a possible solution using Python scripting code: One possibility would be to spawn the child process with popen, so its output will come back to the parent to be processed/displayed (if desired) or else completely ignored (create your popen object with stdout=PIPE and stderr=PIPE to be able to retrieve the output from the child). And then a similar question here on Super User, Redirect 7-Zip's command-line output to /dev/null on Windows when extracting a .7z file reports that the issue is mostly the output, and that by sending the output to NULL, you make the system run essentially silent: Try doing this: %COMSPEC% /c "%ProgramFiles%\7-Zip\7z.exe" ... Yes, it does support command line use. Open a command prompt and n...

Boot Ubuntu 16.04 Into Command Line / Do Not Start GUI

Answer : You could disable the display manager service with systemctl . For example if your display manager is lightdm then run: sudo systemctl disable lightdm.service This will prevent the service from starting at boot. Edit : I forgot to mention how to start the GUI. It is as simple as starting the systemd service: sudo systemctl start lightdm.service Instead of text use runlevel 3 : GRUB_CMDLINE_LINUX="3" # To remove all the fancy graphics you need to get rid of `splash`. GRUB_CMDLINE_LINUX_DEFAULT=”quiet” # Uncomment to disable graphical terminal (grub-pc only) GRUB_TERMINAL=console Then update-grub and reboot. But you really only need GRUB_CMDLINE_LINUX="3" . For quick test hit ESC during booting to get into the grub boot menu. Then press e and find the line which specifies kernel and add 3 at the end: linux /vmlinuz root=/dev/mapper/ubuntu ro 3 Boot it with CTRL + x Ideally I also want to be able to start GUI by typ...

Call Ghostscript In Windows By Its Invocation Name?

Answer : There are several possibilities. To list the two most frequent ones: c:\full\path\to\gswin32c.exe should always work. For 64bit systems, use c:\full\path\to\gswin64c.exe . After a fresh installation using a standard windows installer, you may need to reboot before the updated %path% environment variable is used. Open a cmd window and (assuming your Ghostscript installation ended up in c:\path\to\gs ...) then type set path=c:\path\to\gs\gs9.02\bin;%path% . From this same cmd window you can now simply use gswin32c to start Ghostscript (use gswin64c on 64 bit Windows)...

Can Jconsole Data Be Retrieved From The Command Line?

Answer : jconsole just provides a wrapper around the JMX MBeans that are in the platform MBeanServer . You can write a program to connect to your VM using the Attach API which would then query the MBeans. Or you can expose the platform MBeanServer over RMI and query the MBeans that way. See the java.lang.management package for more info Maybe jvmtop is worth a look. It's a command-line tool which provides a live-view for several metrics. Example output of the VM overview mode: JvmTop 0.4.1 amd64 8 cpus, Linux 2.6.32-27, load avg 0.12 http://code.google.com/p/jvmtop PID MAIN-CLASS HPCUR HPMAX NHCUR NHMAX CPU GC VM USERNAME #T DL 3370 rapperSimpleApp 165m 455m 109m 176m 0.12% 0.00% S6U37 web 21 11272 ver.resin.Resin [ERROR: Could not attach to VM] 27338 WatchdogManager 11m 28m 23m 130m 0.00% 0.00% S6U37 web 31 19187 m.jvmtop.JvmTop 20m 3544m 13m 130m 0.93% 0.47% S6U37 web 20 16733 artup.Bootstrap 159m...

Apple - Change Default Shell From Bash To Zsh

Image
Answer : macOS Catalina and later (10.15+) Apple replaced bash with zsh as the default shell. See article. So no need to do anything. You can verify the default shell by typing echo $0 in the terminal. macOS Mojave and earlier (10.14-) See Apple Support page, Use zsh as the default shell on your Mac Surprisingly this doesn't work with the command line tools as one would expect. This needs to be done with the System Preferences app. The following steps work with multiple versions of Mac OS X through at least 10.11 (El Capitan). Open up the "User's & Groups" panel in the "System Preferences" app. Make sure the panel is unlocked (bottom left) Control click on your username (top left) and select "Advanced Options..." This is only available if you are an Administrator. 4. Change the "Login shell" value to /bin/zsh . 5. Press the OK button to save your change. You should be careful not to change any other f...