Use this command if you want to rename all subtitles for them to have the same name as the mp4 files. NOTE: The order of "ls -1 *.mp4" must match the order of "ls -1 *.srt", run the command bellow to make sure the *.srt files will really match the movies after run this command: paste -d:
this oneliner uses make and it's jobserver for parallel execution of your script. The '-j' flag for make defines number of subprocesses to launch, '-f' tells make use stdin instead of Makefile. Also make have neat flag '-l', which "Specifies that no new jobs (commands) should be started if there are others jobs running and the load is at least load (a floating-point number)."
Also you can use plain Makefile, for better readability:
targets = $(subst .png,.jpg,$(wildcard *.png))
(targets):
echo convert $(subst .jpg,.png,$@) $@
all : $(targets)
Convert some SVG files into PNG using ImageMagick's convert command. Run the conversions in parallel to save time. This is safer than robinro's forkbomb approach :-) xargs runs four processes at a time -P4
This function does a batch edition of all OOO3 Writer files in current directory. It uses sed to search a FOO pattern into body text of each file, then replace it to foo pattern (only the first match) . I did it because I've some hundreds of OOO3 Writer files where I did need to edit one word in each ones and open up each file in OOO3 gui wasn't an option. Usage: bsro3 FOO foo
This is a command to be used inside of MS-DOS batch files to check existence of commands as preconditions before actual batch processing can be started. If the command is found, batch script continues execution. If not, a message is printed on screen, script then waits for user pressing a key and exits. An error message of the command itself is suppressed for clarity purpose. Show Sample Output
This command requires the imagemagick libraries and will resize all files with the .jpg extension to a width of 1024 pixels and will keep the same proportions as the original image.
Convert some SVG files into PNG using ImageMagick's convert command.
Use GNU Parallel: short, easy to read, and will run one job per core.
Resizes all images in the curent directory to x resolution. It is better than `mogrify -resize *.jpg` because of independence from extension of image (e.g. .jpg and .JPG) (: Show Sample Output
- Backup data before reszie as it over write original -To preserve aspect ratio remove !
While `echo rm * | batch` might seem to work, it might still raise the load of the system since `rm` will be _started_ when the load is low, but run for a long time. My proposed command executes a new `rm` execution once every minute when the load is small. Obviously, load could also be lower using `ionice`, but I still think this is a useful example for sequential batch jobs. Show Sample Output
Replace
'/tmp/file 1.txt' '/tmp/file 2.jpg'
with
"$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
for Nautilus script
Or with
%F
for Thunar action
If you linking the symlinks itself, but want to link to source files instead of symlinks, use
"`readlink -m "$i"`"
instead of
"$i"
like this:
for i in '/tmp/file 1.txt' '/tmp/file 2.jpg'; do ln -s "`readlink -m "$i"`" "$i LINK"; done
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Show Sample Output
convert all *.svg to png _in parallel_ this speeds up the conversion for many files, but might also not be feasible for a large number of files
We had a number of git tags named similarly to: 2016.12.13.devel.feature 2016.12.14.master.release But we have multiple developers making commits and tags for testing purposes. I wanted to reduce the number of tags that displayed on our cloud hosting server when doing a deployment.
Usually the MS-DOS cmd.exe processes in the whole FOR loop as one command and expands each var like %varname% in before (except the loop var of course).
This command enables expansion of other vars than only the loop var during the FOR loop. The syntax of the var to expand is then !varname! inside the FOR loop.
Use command
endlocal
to end the setlocal command.
E.g. (only works from batch files, not from commandline directly):
@echo off
setlocal enabledelayedexpansion
FOR %%A IN (*) DO (
set file=%%A
echo !file!
)
endlocal
Batch resize all images to a width of 'X' pixels while maintaing the aspect ratio. This makes uses of ImageMagick to make life easier.
Loops over array of a system var, splits its values and puts the values into %A, %B, %C, %D, and so on.
Create array before, like
set ARRAY[0]=test1,100
and
set ARRAY[1]=test2,200
Be sure to replace %A, %B, etc. with %%A, %%B, etc. when using this from inside of batch files.
Show Sample Output
This command loops over all indexes of the system variable array ARRAY[] and puts its content into %A.
Create this array before, e.g. by
set ARRAY[0]=test1
and
set ARRAY[1]=test2
For using inside of a batch file, write %%A instead of %A.
Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: