this is a script i've been using for a while now with great success. what it does is clean up filenames so they are good to go on a linux-system. this means spaces will be replaced by underscores and special characters will be removed. also, the filename will be converted to lowercase. i've been using this mainly to clean up my mp3-files.
I've found this script, but I don't understand how it works.
#!/bin/bash
shopt -s nullglob
for dir; do
[[ -d $dir ]] || continue
jpgs=( "${dir}"/*.jpg )
if (( "${#jpgs[@]}" )); then
[[ -d ${dir}/Covers ]] || mkdir "${dir}/Covers"
# Avoiding race condition by not reusing the jpgs array
for jpg in "${dir}"/*.jpg; do
mv "$jpg" "${dir}/Covers"
d
Script files
A shellscript usually resides inside a file. This file can be executable, but you can also call a Bash with that filename as parameter:
bash ./myfile
There is no need to add a boring filename extension like .bash or .sh. This is UNIX(r), where executables are not tagged by the extension, but by permissions (filemode). Of course, you can name the file like you want!
I know i'm asking a lot of questions, but im just starting to learn this and it is very different that c
so heres my new question
im writing a script that changes file extension and or ending of files with not extensions. I have the code working to change the extension, but i'm trying to tell the user when they enter an extension that does not exist so they know there was an error in input.
I want to type only the filename of a gcc source that has ".syn" as an extension and copy it, changing the extension to ".c" so it can be compiled.
I do it as follows:
Code:
if (-e $1.syn) then
/bin/cp $1.syn $1.c
endif
This works fine, but if I want to repeat the compilation by recovering the previous call using history, t
I want my script to read a bunch of filenames (which may have spaces) given either as a glob or from STDIN and do stuff with them.
Hi everyone,
So I'm trying to make a Nautilus bash script that will allow me to create a directory based off of a file's name
Example: file.gets.named.here.xxx (xxx in place of extension) - then I can highlight the file and make a directory named after it.
Pretty simple but it comes in handy for organizing my multimedia.
I want to create a bash completion script which recognises arguments of the form --arg and --some-arg=file.
After reading this tutorial and some examples in /usr/share/bash_completion/completions/, I've written the following script (to save time at typing some flags with Chromium):
_chromium()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[
Dear all,
I am successfully execute the below command in my script :
sed '/findstring/s//replacestring/g' find1.txt > /root/Desktop/output1.txt
but when I want to replace it with some runtime input it fails .
I want to accept a string from user and then find, replace it.
Below is my script :
#/bin/bash
#Script for Find and Replace
#filename=$1
findstring=$1
replacestring=$2
echo $find