Read a filename while running and insert it (bash) - bash

I'm new to bash so I need a lot of help for probably a little thing. I'll try to explain, what I want to do or where I need help. (Excuse my english if I make mistakes)
There is a Script, which creates a numbers of .gv Files. In those .gv Files are some commands to make a graph. With "dot" I'm gonna create a picture with that.
My code now is
dot -Tsvg *.gv -o ????.svg
I need help with those ???? - In the *.gv are all .gv listed (you know what I mean I guess...) anyway, the ????'s should have the same name as the file,but there are more than one file so I don't know how to code that. It just should take the Filename while it's running.

The -O option generates names for you, based on the input name and the output format.

Related

Possible to copy/move/etc multiple files of same base name via Windows CMD/.BAT?

I am wondering if it is possible to accomplish the following, given some context and example.
I have files in "Server\Share\Folder\File##.ext"
Sometimes the "File##.ext" can be "File01.ext" through "File20.ext", and other times it may be "File01.ext" through "File40.ext"
Sometimes there are less of these files, sometimes there are more.
I want a batch file to take the files from "Server\Share\Folder\File##.ext" and move them to "Server\Share\OtherFolder\File##.ext". I know I can accomplish this easily with:
copy /y "Server\Share\Folder\File01.ext" "Server\Share\OtherFolder\File01.ext"
Then just add another line for each extra "File02.ext, File03.ext, etc., but I am wondering if it is possible to make it so that any file that resembles "File##.ext" can be included, so that no matter how many ## I have, it always works without issue.
Thanks in advance for any and all advice!
EDIT
Someone mentioned using Wildcards, but my question with that is - lets say those files are File01.ext through File05.ext, will it match what it finds to the newly moved file? Like will it find File01 from File?? on the source and Make it File01 from File?? at the destination?
You can accomplish this task with a FORloop program in batch-file.
You can also loop through the Commands using : and variable name.
Combining these two would help you get what you want.
We can help you with Ideas and little bit of the coding. But the Efforts must be done by you. So U can learn programming better

Maximum number of input file for Ghostscript (gs)

I simply want to combine multiple eps files into one big file using gs command
the command work flawlessly except that when I specify more than 20 input files.
Somehow the command ignore input files starting from 21st input.
Anyone experience the same behavior? Is there a cap of number of input files specify anywhere?
I look through the site and couldn't find one.
sample command
gs -o output.eps -sDEVICE=eps2write file1.eps file2.eps .... file21.eps
Thank you.
Edit: add sample command
Almost certainly you have simply reached the maximum length of the command line for your Operating System. You can use the # syntax for Ghostscript to supply a file containing the command line instead.
https://www.ghostscript.com/doc/current/Use.htm#Input_control
Note that the EPS files will not be placed appropriately using that command, and this does not actually combine EPS files, it creates a new EPS file whose marking content should be the same as the input(s).
If you actually want to combine the EPS files its easy enough, but will require a small amount of programming to parse the EPS file headers and produce appropriate scale/translate operations, as well as stripping off any bitmap previews (which will also happen when you run them through Ghostscript).

sorting sections of text file content with ms-dos commands

I have a bunch of configuration files which I want to sort their content. The file has sections in it, like the example below.
First, I need to sort the sections. Then, I need to sort the lines in each section.
I am looking for some hints on how to do this automatically with batch of ms-dos commands.
What are the main steps? Which commands to be used?
I will be grateful for your hints.
Thank you.
[DEF]
ITY=YES
WEKTY=NO
WKEOW=50
ADFGG=3
SDF=YES
[ABC]
KASDF=AB
WERY=59
KAKSDOE=YES
ABEE=NO
PTOP=MAX
WWQ=98
...and so on

Creating a Continuous File Reading-Executing Shell Script

I need to write something that will read and execute all the files(Mainly executable scripts) inside one or more folders; in other words, a continuous chain with a break when finished. I'm new to shell and need syntax help. I'm on Ubuntu 12.10-Gnome btw.
Here are some main highlights I think should be included;
-The program should ask for one or more directories. Should process all the files given in these directories,
-Should create a .txt file on which files and folders are read and executed(for correction and informational purposes),
-Could contain a break option like control+shift+c maybe but thats clearly not of utmost importance.
The code, or the guidance to the code would be very much appreciated. Thx alot.

Figure out the destination of `ln -s` using script

First, here's the script I'm talking about:
https://github.com/Greduan/dotfiles/blob/master/scripts/symlinks.sh
Check line 20. It has the following content
dest = "$HOME/.`basename \"${source%.*}\"`"
Since I took this from another script, I have no idea what it actually does. I'm guessing what it does is if the source file is named vimrc.vim.symlink it'll output .vimrc.vim, correct?
If not correct, could you please explain what it does?
And could you please help me figure out how to make it so that if the file is vimrc.vim.symlink, how can I make it so that I can get .vimrc?
Please check the script so that you can understand what I'm talking about. :)
First of all, your analysis is correct. ${source%.*} removes the .* suffix from source. The rest, $HOME/.$(basename \"...\") takes the basename of source, which removes all path from it, leaving only the file name and is placed after $(HOME)/..
If you want to remove everything after (and including) the first dot, you can use ${source%%.*} (with %% instead of %). This answer gives you examples.

Resources